cbaggers / cepl

Code Evaluate Play Loop
BSD 2-Clause "Simplified" License
859 stars 52 forks source link

CEPL corrupting something in Drakma? #337

Open cbaggers opened 5 years ago

cbaggers commented 5 years ago
10:21 <MetaYan> I tracked down a weirdness that's been bugging me
                for a while. I usually build a CEPL runtime,
                whenever a new SBCL version appears (sounds like it
                appears from the heavens or something).
10:22 <MetaYan> If I then use drakma or dexador, there is trouble
                in cl+ssl .
10:23 <MetaYan> I've found that if dexador or drakma is loaded
                before CEPL, it works fine, but if CEPL is loaded
                first, I get an unhandled memory error.
10:23 <MetaYan> That's how far I got with it last night.
10:23 <Baggers> that is some jank right there
10:24 <MetaYan> Easy test:
10:24 <MetaYan> (ql:quickload '(:drakma :cepl)) (length (dex:get
                "https://google.com"))
10:24 <MetaYan> (ql:quickload '(:cepl :drakma)) (length (dex:get
                "https://google.com"))
10:25 <MetaYan> With a fresh SBCL 1.5.7
metayan commented 5 years ago

A copy/paste error sneaked in above, so here's a correction.

This works:

(ql:quickload '(:drakma :cepl))
(length (drakma:http-request "http://lisp.org"))

Switching the order of loading the packages:

(ql:quickload '(:cepl :drakma))
(length (drakma:http-request "http://lisp.org"))

leads to

CORRUPTION WARNING in SBCL pid 95696(tid 0x7fffb3b92380):
Memory fault at 0x0 (pc=0x7fff7903e148, fp=0x4fe970, sp=0x4fe920) tid 0x7fffb3b92380
The integrity of this image is possibly compromised.
Continuing with fingers crossed.

debugger invoked on a SB-SYS:MEMORY-FAULT-ERROR in thread
#<THREAD "main thread" RUNNING {10004F04C3}>:
  Unhandled memory fault at #x0.
Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {10004F04C3}>
0: ("bogus stack frame")
1: ("foreign function: SSL_CTX_new")
2: (CL+SSL::SSL-CTX-NEW #<unavailable argument>)
3: (CL+SSL::INITIALIZE :METHOD #<unavailable argument> :RAND-SEED #<unavailable argument>)
4: ((FLET SB-THREAD::WITH-RECURSIVE-LOCK-THUNK :IN CL+SSL:ENSURE-INITIALIZED))
5: ((FLET "WITHOUT-INTERRUPTS-BODY-29" :IN SB-THREAD::CALL-WITH-RECURSIVE-LOCK))
6: (SB-THREAD::CALL-WITH-RECURSIVE-LOCK #<CLOSURE (FLET SB-THREAD::WITH-RECURSIVE-LOCK-THUNK :IN CL+SSL:ENSURE-INITIALIZED) {4FEB9B}> #<SB-THREAD:MUTEX "SSL initialization" owner: #<SB-THREAD:THREAD "main thread" RUNNING {10004F04C3}>> T NIL)
7: (CL+SSL:ENSURE-INITIALIZED :METHOD #<unavailable argument> :RAND-SEED #<unavailable argument>)
8: (CL+SSL:MAKE-CONTEXT :METHOD NIL :DISABLED-PROTOCOLS NIL :OPTIONS NIL :SESSION-CACHE-MODE 2 :VERIFY-LOCATION :DEFAULT :VERIFY-DEPTH 10 :VERIFY-MODE 0 :VERIFY-CALLBACK NIL :CIPHER-LIST #<(SIMPLE-BASE-STRING 383) ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-RSA-RC4-SHA:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AE... {10073B104F}> :PEM-PASSWORD-CALLBACK CL+SSL::PEM-PASSWORD-CALLBACK)
9: (DRAKMA::MAKE-SSL-STREAM #<SB-SYS:FD-STREAM for "socket 10.1.2.5:58658, peer: 144.76.156.38:443" {1001C41A63}> :CERTIFICATE NIL :KEY NIL :CERTIFICATE-PASSWORD NIL :VERIFY NIL :MAX-DEPTH 10 :CA-FILE NIL :CA-DIRECTORY NIL :HOSTNAME "lisp.org")
10: (DRAKMA:HTTP-REQUEST #<PURI:URI https://lisp.org/> :METHOD :GET :REDIRECT 4 :STREAM NIL :ADDITIONAL-HEADERS NIL :PARAMETERS NIL :PRESERVE-URI T :FORM-DATA NIL)
11: ((LABELS DRAKMA::FINISH-REQUEST :IN DRAKMA:HTTP-REQUEST) NIL NIL)
12: (DRAKMA:HTTP-REQUEST #<PURI:URI http://lisp.org/>)
13: (SB-INT:SIMPLE-EVAL-IN-LEXENV (DRAKMA:HTTP-REQUEST "http://lisp.org") #<NULL-LEXENV>)
14: (SB-INT:SIMPLE-EVAL-IN-LEXENV (LENGTH (DRAKMA:HTTP-REQUEST "http://lisp.org")) #<NULL-LEXENV>)
15: (EVAL (LENGTH (DRAKMA:HTTP-REQUEST "http://lisp.org")))
metayan commented 5 years ago

Did some more digging, and it's most likely not a CEPL issue.

Works:

(ql:quickload '(:cl+ssl :sdl2))
(cl+ssl:ensure-initialized)

Fails:

(ql:quickload '(:sdl2 :cl+ssl))
(cl+ssl:ensure-initialized)

Same behaviour both with SBCL and CCL.

jkordani commented 5 years ago

The latter form does fail for me Clozure Common Lisp Version 1.12-dev (v1.12-dev.5-3-gb5233ade) LinuxX8664

On Mon, Nov 18, 2019 at 5:10 AM metayan notifications@github.com wrote:

Did some more digging, and it's most likely not a CEPL issue.

Works:

(ql:quickload '(:cl+ssl :sdl2)) (cl+ssl:ensure-initialized)

Fails:

(ql:quickload '(:sdl2 :cl+ssl)) (cl+ssl:ensure-initialized)

Same behaviour on CCL.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cbaggers/cepl/issues/337?email_source=notifications&email_token=AAIODYY342EWGJ5D5X3FWTTQUJSZFA5CNFSM4I477S32YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEJ5E5Q#issuecomment-554947190, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIODY4ACTZUY627AW5RG4DQUJSZFANCNFSM4I477S3Q .

metayan commented 4 years ago

Narrowed the issue down - it appears with

(ql:quickload '(:cl-opengl :cl+ssl))
(cl+ssl:ensure-initialized)

Since it has nothing to do with CEPL, a new issue will be created in cl-plus-ssl. This issue can be closed.

cbaggers commented 4 years ago

Thanks so much @metayan I'm not ready to dive back into lisp dev just yet, but this'll help a lot when I do. Hope your doing well!