Skip to content

MSan segfaults under fat LTO #68367

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
nikic opened this issue Jan 19, 2020 · 0 comments · Fixed by #68410
Closed

MSan segfaults under fat LTO #68367

nikic opened this issue Jan 19, 2020 · 0 comments · Fixed by #68410
Labels
A-linkage Area: linking into static, shared libraries and binaries A-sanitizers Area: Sanitizers for correctness and code quality C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nikic
Copy link
Contributor

nikic commented Jan 19, 2020

Running https://github.com/rust-lang/rust/blob/master/src/test/ui/sanitizer-memory.rs under -C lto=fat, the test segfaults with:

==11725==ERROR: MemorySanitizer: SEGV on unknown address 0x3ffe4b748058 (pc 0x5567fb27ac91 bp 0x000000000000 sp 0x7ffe4b747fe0 T11725)
==11725==The signal is caused by a READ memory access.
    #0 0x5567fb27ac90 in xor (/home/nikic/rust/sanitizer-memory+0x63c90)
    #1 0x5567fb27b19d in main (/home/nikic/rust/sanitizer-memory+0x6419d)
    #2 0x7f37be59cb96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
    #3 0x5567fb21eff9 in _start (/home/nikic/rust/sanitizer-memory+0x7ff9)

I ran into this in #67759, because as of LLVM 10 the same happens with ThinLTO as well.

This issue is that __msan symbols gets internalized and DCEd, as they are not part of the exported symbol list.

@jonas-schievink jonas-schievink added A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-sanitizers Area: Sanitizers for correctness and code quality labels Jan 19, 2020
@nikic nikic mentioned this issue Jan 19, 2020
8 tasks
tmandry added a commit to tmandry/rust that referenced this issue Jan 22, 2020
Export weak symbols used by MemorySanitizer

Export weak symbols defined by MemorySanitizer instrumentation, which are used
to implement `-Zsanitizer-memory-track-origins` and `-Zsanitizer-recover=memory`.
Previously, when using fat LTO, they would internalized and eliminated.

Fixes rust-lang#68367.
tmandry added a commit to tmandry/rust that referenced this issue Jan 22, 2020
Export weak symbols used by MemorySanitizer

Export weak symbols defined by MemorySanitizer instrumentation, which are used
to implement `-Zsanitizer-memory-track-origins` and `-Zsanitizer-recover=memory`.
Previously, when using fat LTO, they would internalized and eliminated.

Fixes rust-lang#68367.
tmandry added a commit to tmandry/rust that referenced this issue Jan 22, 2020
Export weak symbols used by MemorySanitizer

Export weak symbols defined by MemorySanitizer instrumentation, which are used
to implement `-Zsanitizer-memory-track-origins` and `-Zsanitizer-recover=memory`.
Previously, when using fat LTO, they would internalized and eliminated.

Fixes rust-lang#68367.
@bors bors closed this as completed in 97ac259 Jan 23, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries A-sanitizers Area: Sanitizers for correctness and code quality C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants