我有一个Rust可执行文件,它纯粹是在Rust生态系统中编译的;没有外部C代码或链接库,没有编译器拖入的内容 .

在Linux上使用ASAN编译后,ASAN会报告单定义规则(ODR)违规 . 我是否应该关注可执行文件的正确性?有哪些常见问题?有什么角落案例?

我的理解是因为我的所有Rust依赖都被编译为 .rlib ,并且因为我的代码都不是外语,并且因为我的代码都没有显式引用外部库,所以编译器应该已经知道我的所有程序'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倾向于忽略ODR违规,因为"nothing I can do about it."

我目前无法生成这方面的最小重复示例,只需要一个足以确定我是否应该足够关心进行调查的答案 .

我用来构建/运行ASAN的命令:

CARGO_INCREMENTAL=0 RUSTFLAGS="-Z sanitizer=address" cargo run --target x86_64-unknown-linux-gnu --example name_of_example

错误消息(删除了可执行文件名和文件路径)

==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)

据我所知,这不是来自我的箱子(我没有观察到不良行为,因此我倾向于不关心)但我有多个相互依赖的箱子在这里得到检验,我不确定这是否能反映出来一些更险恶的潜在问题 .