Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 928333 - dev-python/cryptography-42.0.5 crashes on loong when built with dev-lang/rust
Summary: dev-python/cryptography-42.0.5 crashes on loong when built with dev-lang/rust
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: Loong Linux
: Normal normal (vote)
Assignee: Randy Barlow
Depends on:
Reported: 2024-03-31 21:37 UTC by matoro
Modified: 2024-06-19 14:35 UTC (History)
6 users (show)

See Also:
Package list:
Runtime testing required: ---

gdb context and complete backtrace (file_928333.txt,460.72 KB, text/plain)
2024-03-31 21:37 UTC, matoro

Note You need to log in before you can comment on or make changes to this bug.
Description matoro archtester 2024-03-31 21:37:10 UTC
There's multiple components here, but when built with dev-lang/rust, dev-python/cryptography crashes on import (in libunwind) on loong.  It does not crash when built with dev-lang/rust-bin.  This reproduces in clean stage3.  Demo:

# eselect rust list
Available Rust versions:
  [1]   rust-bin-1.76.0
  [2]   rust-1.76.0 *
# emerge -v1 dev-python/cryptography
# python3 -c 'import cryptography.hazmat.bindings._rust'
Segmentation fault
# eselect rust set 1
# env-update
>>> Regenerating /etc/
# emerge -v1 dev-python/cryptography
# python3 -c 'import cryptography.hazmat.bindings._rust'

Attached is a sample backtrace, from running twisted-regen-cache which is how I discovered it.  Unfortunately the parts after std::panicking::try::do_call seem to be unreliable, as running it against just an import shows a completely different backtrace ending in openssl instead.

Reproducible: Always
Comment 1 matoro archtester 2024-03-31 21:37:46 UTC
Created attachment 889165 [details]
gdb context and complete backtrace
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2024-04-01 03:51:23 UTC
So that sounds like a Rust compiler bug?
Comment 3 matoro archtester 2024-04-01 04:09:32 UTC
(In reply to Michał Górny from comment #2)
> So that sounds like a Rust compiler bug?

Normally I would say yes, but it does not crash when built with rust-bin.  That indicates that there has to be something different in the Gentoo environment building dev-lang/rust vs rust-bin.
Comment 4 Ciprian Ciubotariu 2024-04-01 14:25:07 UTC
Not sure it is related, but I am having somewhat similar problems with the rust module of dev-python/cryptography-42.0.5, which affects ansible-vault downstream. I found the following test line at

python3 -c 'from cryptography.exceptions import InvalidSignature; from cryptography.hazmat.backends import default_backend; from cryptography.hazmat.primitives import hashes, padding; from cryptography.hazmat.primitives.hmac import HMAC; from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC; from cryptography.hazmat.primitives.ciphers import (Cipher as C_Cipher, algorithms, modes); default_backend();'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.11/site-packages/cryptography/", line 9, in <module>
    from cryptography.hazmat.bindings._rust import exceptions as rust_exceptions
ImportError: cannot import name 'exceptions' from 'cryptography.hazmat.bindings._rust' (unknown location)

I am using python-3.11 via eselect, but I have installed:

  3.10.13_p3 (ensurepip gdbm ncurses pgo readline sqlite ssl tk -bluetooth -build -debug -examples -libedit -test -valgrind -verify-sig)
  3.11.8_p1 (ensurepip gdbm ncurses pgo readline sqlite ssl tk -bluetooth -build -debug -examples -libedit -test -valgrind -verify-sig)
  3.12.2_p1 (ensurepip gdbm ncurses pgo readline sqlite ssl tk -bluetooth -build -debug -examples -libedit -test -valgrind -verify-sig)

  42.0.5 (-debug -test PYTHON_TARGETS="python3_10 python3_11 -pypy3 -python3_12")

  1.74.1 (lto -big-endian -clippy -debug -dist -doc -llvm-libunwind -miri -nightly -parallel-compiler -profiler -rust-analyzer -rust-src -rustfmt -system-bootstrap -system-llvm -test -verify-sig -wasm ABI_MIPS="-n32 -n64 -o32" ABI_S390="-32 -64" ABI_X86="32 64 -x32" CPU_FLAGS_X86="sse2" LLVM_TARGETS="X86 -AArch64 -AMDGPU -ARC -ARM -AVR -BPF -CSKY -DirectX -Hexagon -Lanai -LoongArch -M68k -MSP430 -Mips -NVPTX -PowerPC -RISCV -SPIRV -Sparc -SystemZ -VE -WebAssembly -XCore -Xtensa")

while dev-lang/rust-bin is not installed.
Comment 5 matoro archtester 2024-04-01 14:52:22 UTC
Not the same issue, this is loong-specific and results in a segfault, not an ImportError.