ASan across C dynamic library and Rust crate

I have a Rust project blah that links against a dynamic library that's written in C and can be built from source. (There's also a sys crate in between.) I would like to build the dynamic library with -fsanitize=address, and the Rust project with -Z sanitizer=address (plus build-std stuff), and have everything work together. So far I mostly get this error:

==364511==Your application is linked against incompatible ASan runtimes.

I think this is because Rust really wants to link its libasan (presumably the LLVM one?) statically, and that doesn't cooperate with the dynamic library from C, whether I link libasan statically or dynamically when building the latter. What is the way out here?

Just a guess, but I think the issue is that Rust uses a custom patched LLVM, likely with a different version than the one installed on your system. The patch probably wouldn't matter, but the version mismatch would. You can check the version via rustc --version --verbose.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.