Incompatible ASan runtimes when Rust executable links with C shared library that dynamic links asan runtime #114127
Labels
A-sanitizers
Area: Sanitizers for correctness and code quality
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Issues:
when it links a shared library that dynamic links to
libasan.so
,which is provided by gcc 7.5
-static-libasan
in C link flagsThe cause:
RUSTFLAGS=-Zsanitizer=address
, it seems rustc always static links asan runtime,by static link
librustc-nightly_rt.asan.a
bundled with rustc installationlibrustc-nightly_rt.asan.a
Compatibility of asan runtimes of gcc7.5.0 and rustc
According to
__asan_version_mismatch_check_v8
in https://github.com/gcc-mirror/gcc/blob/releases/gcc-7.5.0/libsanitizer/asan/asan_init_version.hAccording to GetAsanVersion function in https://github.com/rust-lang/llvm-project/blob/rustc/16.0-2023-06-05/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
Steps to reproduce
Create C shared lib by
gcc -shared -fPIC segfault.c -o libsegfault.so -fsanitize=address
Producing Rust executable with
Then run the final executable, set environment variable
LD_LIBRARY_PATH
if neededActual result:
Expected result:
Meta
Target platform: x86_64-unknown-linux-gnu
rustc --version --verbose
:gcc --version
Extra notes:
I asked ChatGPT
It answers:
The text was updated successfully, but these errors were encountered: