dexador icon indicating copy to clipboard operation
dexador copied to clipboard

The alien function "CRYPTO_num_locks" is undefined

Open whatacold opened this issue 6 years ago • 3 comments

Hi,

dex:get raises an undefined function error when getting a https URL, for example:

(defvar *url* "https://lispcookbook.github.io/cl-cookbook/web-scraping.html")
(defvar *html* (dex:get *url*))

will result in:

The alien function "CRYPTO_num_locks" is undefined.
     [Condition of type SB-KERNEL::UNDEFINED-ALIEN-FUNCTION-ERROR]

Restarts:
   0: [RETRY] Retry SLIME interactive evaluation request.
   1: [*ABORT] Return to SLIME's top level.
   2: [ABORT] abort thread (#<THREAD "worker" RUNNING {1007B459B3}>)

Backtrace:
    0: ("undefined function")
    1: (CL+SSL::CRYPTO-NUM-LOCKS)
    2: ((FLET SB-THREAD::WITH-RECURSIVE-LOCK-THUNK :IN CL+SSL:ENSURE-INITIALIZED))
    3: ((FLET #:WITHOUT-INTERRUPTS-BODY-386 :IN SB-THREAD::CALL-WITH-RECURSIVE-LOCK))
    4: (SB-THREAD::CALL-WITH-RECURSIVE-LOCK #<CLOSURE (FLET SB-THREAD::WITH-RECURSIVE-LOCK-THUNK :IN CL+SSL:ENSURE-INITIALIZED) {7FFFEE5A56BB}> #<SB-THREAD:MUTEX "SSL initialization" owner: #<SB-THREAD:THREA..
    5: (CL+SSL:ENSURE-INITIALIZED :METHOD #<unavailable argument> :RAND-SEED #<unavailable argument>)
    6: ((LABELS DEXADOR.BACKEND.USOCKET::MAKE-NEW-CONNECTION :IN DEXADOR.BACKEND.USOCKET:REQUEST) #<QURI.URI.HTTP:URI-HTTPS https://lispcookbook.github.io/cl-cookbook/web-scraping.html>)
    7: (DEXADOR.BACKEND.USOCKET:REQUEST #<unavailable argument> :METHOD :GET)
    8: (SB-INT:SIMPLE-EVAL-IN-LEXENV (DEXADOR:GET *URL*) #<NULL-LEXENV>)
    9: (SB-INT:SIMPLE-EVAL-IN-LEXENV (UNLESS (BOUNDP (QUOTE *HTML*)) (DEXADOR:GET *URL*)) #<NULL-LEXENV>)
   10: (SB-INT:SIMPLE-EVAL-IN-LEXENV (SB-IMPL::%DEFVAR (QUOTE *HTML*) (SB-C:SOURCE-LOCATION) (UNLESS (BOUNDP #) (DEXADOR:GET *URL*))) #<NULL-LEXENV>)
   11: (SB-INT:SIMPLE-EVAL-IN-LEXENV (DEFVAR *HTML* (DEXADOR:GET *URL*)) #<NULL-LEXENV>)
   12: (EVAL (DEFVAR *HTML* (DEXADOR:GET *URL*)))
   13: ((LAMBDA NIL :IN SWANK:INTERACTIVE-EVAL))
   --more--

why is that?

versions:

  • CL implementation: SBCL 1.3.18-1.fc26
  • dexador-20170516-git

Thanks.

whatacold avatar Mar 15 '18 15:03 whatacold

Dexador depends on CL+SSL, a wrapper library for OpenSSL. I suppose that you have older OpenSSL since the symbol was introduces at v0.9.4.

CRYPTO_num_locks() was added in OpenSSL 0.9.4

As the v1.1.x is the latest stable release, it may be time to update it.

fukamachi avatar Mar 16 '18 04:03 fukamachi

Thanks for this tip, but with the lastest package, the error remains.

Here is the package on my fedora box:

# dnf list installed openssl-libs openssl
Installed Packages
openssl.x86_64                                                         1:1.1.0g-1.fc26                                                    @updates
openssl-libs.x86_64                                                    1:1.1.0g-1.fc26                                                    @updates

And the library used by sbcl process:

$ cat /proc/`pidof sbcl`/maps | ag ssl
7fffeff34000-7fffeff97000 r-xp 00000000 08:08 2649888                    /usr/lib64/libssl.so.1.1.0g
7fffeff97000-7ffff0196000 ---p 00063000 08:08 2649888                    /usr/lib64/libssl.so.1.1.0g
7ffff0196000-7ffff019a000 r--p 00062000 08:08 2649888                    /usr/lib64/libssl.so.1.1.0g
7ffff019a000-7ffff01a0000 rw-p 00066000 08:08 2649888                    /usr/lib64/libssl.so.1.1.0g

I installed dexador(therefore cl+ssl) via quicklisp, and cl+ssl's version is (haven't figured out how to get the version yet:-(, but it seems it's part of its installation path ): * (ql:where-is-system "cl+ssl")

#P"/home/whatacold/quicklisp/dists/quicklisp/software/cl+ssl-20170403-git/"

whatacold avatar Mar 16 '18 15:03 whatacold

This symbol is a macro in openssl v1.1.0:

openssl-1.1.0g $ ag CRYPTO_num_locks
CHANGES
11112:  *) New function "CRYPTO_num_locks" that returns CRYPTO_NUM_LOCKS.

include/openssl/crypto.h
220:#  define CRYPTO_num_locks()            (1)

And a function in openssl v0.9.6:

openssl-0.9.6 $ ag CRYPTO_num_locks
.
.
.
crypto/crypto.h
291:int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */

crypto/cryptlib.c
161:int CRYPTO_num_locks(void)

CHANGES
2129:  *) New function "CRYPTO_num_locks" that returns CRYPTO_NUM_LOCKS.

So maybe I'd better file this issue to cl+ssl.

whatacold avatar Mar 17 '18 04:03 whatacold