py-cryptography: cryptography.hazmat.bindings._rust crashes Python interpreter

dl8dtl

Developer
Since some recent update (sorry, can't nail it down more exactly), py-cryptography crashes the Python interpreter here.
I could nail it down to

Code:
% python3.11
Python 3.11.10 (main, Nov  3 2024, 08:40:35) [Clang 18.1.6 (https://github.com/llvm/llvm-project.git llvmorg-18.1.6-0-g1118c2 on freebsd13
Type "help", "copyright", "credits" or "license" for more information.
>>> import cryptography.hazmat.bindings._rust
Objects/typeobject.c:4083: type_dealloc: Assertion "type->tp_flags & (1UL << 9)" failed
Enable tracemalloc to get the memory block allocation traceback

object address  : 0x821fd3998
object refcount : 0
object type     : 0x821ff64b8
object type name: type
object repr     : <refcnt 0 at 0x821fd3998>

Fatal Python error: _PyObject_AssertFailed: _PyObject_AssertFailed
Python runtime state: initialized

Current thread 0x000000082817a000 (most recent call first):
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 1233 in create_module
  File "<frozen importlib._bootstrap>", line 573 in module_from_spec
  File "<frozen importlib._bootstrap>", line 676 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1147 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1176 in _find_and_load
  File "<stdin>", line 1 in <module>

Extension modules: _cffi_backend (total: 1)
Abort (core dumped)
Using GDB, I can see that the cryptography Rust code somehow tries to deallocate the AttributeError standard exception.
I recompiled all the related ports (cpython, cffi, rust compiler), the crash remains.

Any ideas what might have gone wrong?
 
Minor update: dropping in the official package gets rid of the issue.
So it must be something with rust building my own …
 
Back
Top