I have a Rust executable which was compiled purely within the Rust ecosystem; no external C code or linked libraries, sans whatever the compiler drags in.
After compiling it with ASAN on Linux, ASAN reports a one-definition-rule (ODR) violation. Should I have concerns about the correctness of my executable? What are some common concerns? What are some corner cases?
My understanding is that because all my Rust dependencies were compiled to .rlib
s, and because none of my code is in a foreign language, and because none of my code explicitly refers to foreign libraries, the compiler should have been aware of all of my program's symbol names at compile time, with the possible exception of system libraries that it drags in itself and thus should be aware of. Thus I'm leaning towards ignoring the ODR violation as "nothing I can do about it."
I'm not able to produce a minimal repro example of this currently, and merely need an answer that gives me enough to determine whether or not I should care enough to investigate.
The command that I used to build/run with ASAN:
CARGO_INCREMENTAL=0 RUSTFLAGS="-Z sanitizer=address" cargo run --target x86_64-unknown-linux-gnu --example name_of_example
The error message (with the executable name and file path removed)
==18003==ERROR: AddressSanitizer: odr-violation (0x5625fb39f760):
[1] size=0 'ref.c' executable_name_here12-d0d02bd82d5d1b2688ff68a1707ea7a1.rs
[2] size=0 'ref.l' executable_name_here10-d0d02bd82d5d1b2688ff68a1707ea7a1.rs
These globals were registered at these points:
[1]:
#0 0x5625fb2a5727 in __asan_register_globals.part.11 /checkout/src/libcompiler_builtins/compiler-rt/lib/asan/asan_globals.cc:338
#1 0x5625faf4e26d in asan.module_ctor (/executable/path/here+0x1c326d)
[2]:
#0 0x5625fb2a5727 in __asan_register_globals.part.11 /checkout/src/libcompiler_builtins/compiler-rt/lib/asan/asan_globals.cc:338
#1 0x5625fae9d9cd in asan.module_ctor (/executable/path/here+0x1129cd)
As far as I can tell, this isn't from my crates (and I don't otherwise observe bad behavior, hence my leaning towards not caring) but I have multiple interdependent crates getting instrumented here, and am not sure if this could reflect some more sinister underlying problem.
__asan_register_globals.part.11
) don't occur in the code when compiling without ASAN (i.e. no-Z sanitizer=address
), insofar as my grepping the output ofnm
on the compiled binaries for the stringasan
goes. I'm not sure, but this might be a bug in the ASAN hooks generated byrustc
? I'unno. – Frydman