-
-
Notifications
You must be signed in to change notification settings - Fork 15
Closed
Labels
Description
Solution to issue cannot be found in the documentation.
- I checked the documentation.
Issue
Thank you for the the fix to statically link against libzstd @h-vetinari
zstandard fails to work when the newer libzstd's symbols are loaded into the process table.
Here is a repro:
import ctypes
import os
import sys
lib_os = ctypes.CDLL('/miniconda3/envs/dev/lib/libzstd.so', mode=os.RTLD_GLOBAL) # 1.5.7 libzstd
import zstandard # FAILS
# ImportError: zstd C API versions mismatch; Python bindings were not compiled/linked against expected zstd version (10507 returned by the lib, 10506 hardcoded in zstd headers, 10506 hardcoded in the cext)The call to ZSTD_versionNumber is indirect and points to a relocation entry, which the dynamic linker fixes up with the address of the function in the previously loaded shared object. Presumably the point of statically linking libzstd was to isolate backend_c from the outside world, which seems to be violated here.
$ objdump -Cdr /miniconda3/envs/dev/lib/python3.11/site-packages/zstandard/backend_c.cpython-311-x86_64-linux-gnu.so
...
000000000001c690 <zstd_module_init>:
1c690: 41 54 push %r12
1c692: 55 push %rbp
1c693: 53 push %rbx
1c694: 48 89 fb mov %rdi,%rbx
1c697: ff 15 83 ce 0e 00 call *0xece83(%rip) # 109520 <ZSTD_versionNumber@@Base+0xe9e30>
$ readelf -a /miniconda3/envs/dev/lib/python3.11/site-packages/zstandard/backend_c.cpython-311-x86_64-linux-gnu.so
...
Relocation section '.rela.dyn' at offset 0xd258 contains 1150 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000109520 007a00000006 R_X86_64_GLOB_DAT 000000000001f6f0 ZSTD_versionNumber + 0
Installed packages
zstandard 0.23.0 py311h9ecbd09_1 conda-forge
zstd 1.5.7 hb8e6e7a_2 conda-forgeEnvironment info
conda version : 25.1.1Reactions are currently unavailable