You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to install cl+ssl on a new M1 mac using quicklisp, it hangs and is pushing me into LDB, showing this error:
This is SBCL 2.0.11, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
* (ql:quickload :cl+ssl)
To load "cl+ssl":
Load 1 ASDF system:
cl+ssl
; Loading "cl+ssl"
.WARNING: /usr/local/Cellar/sbcl/2.0.11/libexec/bin/sbcl is loading libcrypto in an unsafe way
fatal error encountered in SBCL pid 55608 pthread 0x101042e00:
SIGABRT received.
Welcome to LDB, a low-level debugger for the Lisp runtime environment.
ldb>
From #lisp on freenode, @phoe pointed this out while helping me:
By reinstalling Homebrew, sbcl and most importantly openssl making sure that in every step we use rosetta 2 it finally works fine.
I guess some parts of that stack was using arm architecture. The :CL+SSL-FOREIGN-LIBS-ALREADY-LOADED tip was what finally gave me a wrong architecture stacktrace, so thanks :)
@fjl , does the load request for unversioned lib really crashes the process?
@theothornhill says after fixing his packages everything works for him. So I thought the "unsafe way" message is simply a warning for now, not really breaking the load and crashing the process.
says after fixing his packages everything works for him.
It will work if cffi finds the library in /usr/local/lib first, or in any of the other non-system locations.
So I thought the "unsafe way" message is simply a warning for now, not really breaking the load and crashing the process.
The crash happens when loading "/usr/lib/libcrypto.dylib" because it is a stub whose only purpose is to crash the process. You can find other reports of this, for example:
@theothornhill , strange that you can't get the line printed. Maybe remove .fasl files and rebuild (that's an unlined function). On Linux .fals files can be removed by rm -rf ~/.cache/common-lisp/, probably on MacOS it's the same.
@avodonosov@daewok I'm sorry, but I cannot get it to work... I've tried to quickload cffi before quickloading cl+ssl, and also with manually recompiling that function, and the functions it is referenced from, since it's an inlined function.
Using your reference I found out that 'try-foreign-library-alternatives' function in libraries.lisp is loading each library from the library-list parameter without checking if its present at specified location. Here is my solution. For me this fixes the sbcl crashes while loading libcrypto library.
@theothornhill Maybe you can (trace sb-alien:load-shared-object) instead.
@aniketnarvekar That is not a good solution. It looks like your patch is at cffi/cffi#193 (it was mentioned in an earlier comment, not sure why it was deleted).
First, it will not work when loading a system library. You typically do not provide the full path to those, so the probe-file will return NIL except in the unlikely event that *default-pathname-defaults* is bound to the directory containing the library.
Second, Apple has decided to remove ~all system libraries from the file system and store them in a cache elsewhere. So probe-file will never return non-NIL for those. Apple says the correct way to test for library existence is to dlopen them and check for an error. That makes this bug extra rich since it seems that dlopen("/some/non-existent/path/libcrypto.dylib") causes the process to abort instead of returning an error.
Others above already mentioned that moving files to /usr/local/lib fixed it, but here's some explicit steps for anyone else struggling with this on osx (I hit this after updating to Monterey),
brew install openssl (probably installed to /usr/local/opt/openssl@3, or a higher @)
brew link openssldoesn't work, (or any flavor of brew link --force openssl@3) so you need to symlink this custom openssl install manually so cl+ssl can find it
@aniketnarvekar, thank you for confirming a non-existing path crashes the app. I was actually curious to know exactly what path it is - is it one of the path specified in reload.lisp or cffi also falls-back to some default path which causes the crash (reading the cffi code I think it should not, but was curious to be sure).
As for checking the path presence, while @daewok is right that a generic cffi patch is not good for that, we can do that for our specific paths on cl+ssl level. In the commit referenced above I implemented that.
So now we try custom paths only if they are present. I hesitated to remove them altogether - do not want to cause inconvenience for people who may depend on them.
For the record, the custom paths where added in #56.
I'd appreciate if someone tested the last version and confirmed it works on macOS where it previously crashed.
Activity
avodonosov commentedon Jan 25, 2021
I do not really understand the meaning of the "WARNING: /usr/local/Cellar/sbcl/2.0.11/libexec/bin/sbcl is loading libcrypto in an unsafe way".
But if the problem is about the version of libressl, user code can load any version instead of the default behaviour.
See the :CL+SSL-FOREIGN-LIBS-ALREADY-LOADED description in the doc (https://common-lisp.net/project/cl-plus-ssl/)
Let us know if that helps.
phoe commentedon Jan 25, 2021
Seems like "Clients should not load the unversioned libcrypto dylib as it does not have a stable ABI."
https://stackoverflow.com/questions/58272830/ has some pointers to use a different SSL library binary.
theothornhill commentedon Jan 25, 2021
By reinstalling Homebrew, sbcl and most importantly openssl making sure that in every step we use rosetta 2 it finally works fine.
I guess some parts of that stack was using arm architecture. The
:CL+SSL-FOREIGN-LIBS-ALREADY-LOADEDtip was what finally gave me a wrong architecture stacktrace, so thanks :)fjl commentedon Jan 31, 2021
It's fixed in my PR.
avodonosov commentedon Jan 31, 2021
@fjl , does the load request for unversioned lib really crashes the process?
@theothornhill says after fixing his packages everything works for him. So I thought the "unsafe way" message is simply a warning for now, not really breaking the load and crashing the process.
theothornhill commentedon Jan 31, 2021
Yes, it does work for me. However, it seems like a known problem, so I might just be lucky for some reason :)
fjl commentedon Jan 31, 2021
It will work if cffi finds the library in /usr/local/lib first, or in any of the other non-system locations.
The crash happens when loading "/usr/lib/libcrypto.dylib" because it is a stub whose only purpose is to crash the process. You can find other reports of this, for example:
avodonosov commentedon Mar 6, 2021
Closing this - versioned paths were added in #115
slyrus commentedon Oct 9, 2021
FWIW, I just got this on a fresh install. Not sure what I'm doing wrong.
avodonosov commentedon Oct 10, 2021
@slyrus , probably none of the versioned paths used at
cl-plus-ssl/src/reload.lisp
Line 53 in d4c95b5
and
cl-plus-ssl/src/reload.lisp
Line 101 in d4c95b5
are present on your machine.
Please check what version do you have instead.
You can can load them with https://common-lisp.net/project/cl-plus-ssl/#define-libssl-path.
If that works we can add those versions to the default lists.
slyrus commentedon Oct 10, 2021
Using the latest cl+ssl fixed things. Not sure what's changed between HEAD and what's in quicklisp, but the workaround is good enough for me. Thanks!
ngn999 commentedon Nov 2, 2021
I have the same problem on M1.
cl+ssl/configwill work, but my project needs deployed to linux.And I found this patch will work:
but I don't know why.
fjl commentedon Nov 4, 2021
Someone needs to dig into the dyld_shared_cache on Monterey and check which libssl versions it supports. I don't have Monterey yet, so can't check.
19 remaining items
theothornhill commentedon Nov 19, 2021
I cannot seem to get
cffito print that line, since it seems to crash before we get there.This reproduces for me too.
avodonosov commentedon Nov 21, 2021
@theothornhill , strange that you can't get the line printed. Maybe remove .fasl files and rebuild (that's an unlined function). On Linux .fals files can be removed by
rm -rf ~/.cache/common-lisp/, probably on MacOS it's the same.daewok commentedon Nov 22, 2021
@theothornhill @avodonosov I think the wrong line to edit was mentioned. It should be https://github.com/cffi/cffi/blob/eac416d11bb483c33c277d164b4c6daccd9af452/src/cffi-sbcl.lisp#L366 (cffi-sbcl.lisp instead of cffi-scl.lisp)
theothornhill commentedon Nov 22, 2021
Thanks, I wondered if that could be the case. I'll check tonight :)
theothornhill commentedon Nov 23, 2021
@avodonosov @daewok I'm sorry, but I cannot get it to work... I've tried to quickload
cffibefore quickloadingcl+ssl, and also with manually recompiling that function, and the functions it is referenced from, since it's an inlined function.What am I missing?
avodonosov commentedon Nov 23, 2021
Difficwlt to say what is missing...
aniketnarvekar commentedon Nov 24, 2021
Using your reference I found out that 'try-foreign-library-alternatives' function in libraries.lisp is loading each library from the library-list parameter without checking if its present at specified location. Here is my solution. For me this fixes the sbcl crashes while loading libcrypto library.
daewok commentedon Nov 24, 2021
@theothornhill Maybe you can
(trace sb-alien:load-shared-object)instead.@aniketnarvekar That is not a good solution. It looks like your patch is at cffi/cffi#193 (it was mentioned in an earlier comment, not sure why it was deleted).
First, it will not work when loading a system library. You typically do not provide the full path to those, so the
probe-filewill return NIL except in the unlikely event that*default-pathname-defaults*is bound to the directory containing the library.Second, Apple has decided to remove ~all system libraries from the file system and store them in a cache elsewhere. So
probe-filewill never return non-NIL for those. Apple says the correct way to test for library existence is todlopenthem and check for an error. That makes this bug extra rich since it seems thatdlopen("/some/non-existent/path/libcrypto.dylib")causes the process to abort instead of returning an error.avodonosov commentedon Nov 27, 2021
Anyone sees a problem if I remove all non-standard paths for Darwin - leaving only /usr/lib/libssl.NN.dylib ?
daewok commentedon Nov 29, 2021
Seems reasonable, especially since
cl+ssl/configwas introduced.jaemk commentedon Dec 7, 2021
Others above already mentioned that moving files to
/usr/local/libfixed it, but here's some explicit steps for anyone else struggling with this on osx (I hit this after updating to Monterey),brew install openssl(probably installed to/usr/local/opt/openssl@3, or a higher@)brew link openssldoesn't work, (or any flavor ofbrew link --force openssl@3) so you need to symlink this custom openssl install manually so cl+ssl can find it/usr/local/lib/libssl.dylib/libcrypto.dylibIn total:
On macOs only load custom installation(s) of OpenSSL if they are pres…
avodonosov commentedon Dec 9, 2021
@aniketnarvekar, thank you for confirming a non-existing path crashes the app. I was actually curious to know exactly what path it is - is it one of the path specified in reload.lisp or cffi also falls-back to some default path which causes the crash (reading the cffi code I think it should not, but was curious to be sure).
As for checking the path presence, while @daewok is right that a generic cffi patch is not good for that, we can do that for our specific paths on cl+ssl level. In the commit referenced above I implemented that.
So now we try custom paths only if they are present. I hesitated to remove them altogether - do not want to cause inconvenience for people who may depend on them.
For the record, the custom paths where added in #56.
I'd appreciate if someone tested the last version and confirmed it works on macOS where it previously crashed.
Include re-detection of custom OpenSSL installations into the RELOAD …
When detecting custom OpenSSL installations for macOS, use a run-time…