Skip to content

Memory sanitizer on shared library issue #112430

@VA-GS

Description

@VA-GS

Hello, is there a way to make a shared library built with Memory sanitizer that is importable from Python ? I tried with Pybind11 and I am getting either undefined symbols on the import or if I link libclang_rt.msan-x86_64.a explicitly, I get relocation R_X86_64_TPOFF32 against __msan::is_in_symbolizer_or_unwinder cannot be used with -shared.

To keep it simple, the example below does not add Pybind11 to the mix:

/*
clang++ -o msan_test.so -shared -fsanitize=memory msan_test.cpp -fuse-ld=lld -stdlib=libc++ -v -Wl,-v

python -c "import msan_test"
undefined symbol: __msan_init

clang++ -o msan_test.so -shared -fsanitize=memory msan_test.cpp -fuse-ld=lld -stdlib=libc++ -v -Wl,-v /usr/lib/llvm-18/lib/clang/18/lib/linux/libclang_rt.msan-x86_64.a
relocation R_X86_64_TPOFF32 against msan_expect_umr cannot be used with -shared
*/
int main() {
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions