oracle / graalpython

A Python 3 implementation built on GraalVM
Other
1.2k stars 103 forks source link

SEGFAULT when doing `from cryptography.hazmat.bindings.openssl import binding` (with cryptography 3.4.7) #329

Closed jiridanek closed 1 year ago

jiridanek commented 1 year ago

I tried several ways to build with openssl 1.1.1, but every which way, I get a VM segfault when I import the built library

Is there something I can do to further debug the crash? Should I (somehow) try to build openssl for GraalVM myself, instead of linking to native shared library?

$ env CFLAGS="-I/nix/store/syx9zczfg4p6x013lyg4j6nr1fqj4l9m-openssl-1.1.1l-dev/include" LDFLAGS="-L/nix/store/hl09r5178s52savxh4pmkg86jjlakd4p-openssl-1.1.1l/lib" venvgpy_nightly/bin/graalpy -m pip install -U cryptography --force-reinstall --no-binary cryptography
$ LD_LIBRARY_PATH=/nix/store/hl09r5178s52savxh4pmkg86jjlakd4p-openssl-1.1.1l/lib venvgpy_nightly/bin/graalpy -c 'from cryptography.hazmat.bindings.openssl import binding'

stacktrace.txt

jiridanek commented 1 year ago

The relevant area of cryptography changelog, https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst#348---2021-08-24

msimacek commented 1 year ago

I can reproduce it. It seems it's failing in a call to a native function from the cffi module. I'll have a look.

jiridanek commented 1 year ago

Now I got the following. I am not sure if it counts as success, yet.

$ LD_LIBRARY_PATH=/nix/store/hl09r5178s52savxh4pmkg86jjlakd4p-openssl-1.1.1l/lib venvgpy_nightly/bin/graalpy -c 'from cryptography.hazmat.bindings.openssl import binding'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/jdanek/venvgpy_nightly/lib/python3.10/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 172, in <module>
    Binding.init_static_locks()
  File "/home/jdanek/venvgpy_nightly/lib/python3.10/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 146, in init_static_locks
    cls._ensure_ffi_initialized()
  File "/home/jdanek/venvgpy_nightly/lib/python3.10/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 136, in _ensure_ffi_initialized
    cls.lib = build_conditional_library(lib, CONDITIONAL_NAMES)
  File "/home/jdanek/venvgpy_nightly/lib/python3.10/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 102, in build_conditional_library
    setattr(conditional_lib, attr, getattr(lib, attr))
NotImplementedError: op=15
jiridanek commented 1 year ago

yes, that was a success, and paramiko library now works, when installed like this

venvgpy_nightly/bin/graalpy -m pip install paramiko 'bcrypt<4'
msimacek commented 1 year ago

Hmm, I can import it fine. Since the fix was about updating a patch for cffi, could you please try reinstalling cffi with --no-cache-dir option? It's possible that it's picking up the broken wheel from the cache.