FS#46913 - [llvm] MemorySanitizer is defunct on newer kernels

Attached to Project: Arch Linux
Opened by Peter Wu (Lekensteyn) - Thursday, 29 October 2015, 21:16 GMT
Last edited by Evangelos Foutras (foutrelis) - Saturday, 31 October 2015, 12:15 GMT
Task Type Bug Report
Category Upstream Bugs
Status Closed
Assigned To Evangelos Foutras (foutrelis)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
Any program built with -fsanitize=memory will fail to run with LLVM 3.7.0 and Linux 4.1.2 and newer. On startup, the program will fail with:

FATAL: Code 0x563b3a270d20 is out of application range. Non-PIE build?
FATAL: MemorySanitizer can not mmap the shadow memory.
FATAL: Make sure to compile with -fPIE and to link with -pie.
FATAL: Disabling ASLR is known to cause this error.
FATAL: If running under GDB, try 'set disable-randomization off'.

Upstream has pushed a fix for this bug (https://llvm.org/bugs/show_bug.cgi?id=24155), but based on their previous release schedules, it will probably take at least until Feb2016 before the fix is shipped with 3.8.0. Can the patch be considered for inclusion? Although an ABI break is mentioned, the kernel incompatibility has been there for almost 4 months (linux 4.1.2-1). There have been other (unsuspecting) reports of this issue as well: https://github.com/golang/go/issues/12898

I have included a squashed patch for the llvm+compiler-rt changes and an unrelated fix for a scan-build issue with cmake+clang (https://llvm.org/bugs/show_bug.cgi?id=13237). They both apply trivially:

# https://llvm.org/bugs/show_bug.cgi?id=24155
patch -Np1 -i ../new-msan-mapping.patch

# https://llvm.org/bugs/show_bug.cgi?id=13237
patch -d tools/clang -Np1 < ../scan-build-clang-fix.patch

Builds for me and is also helpful :) Tip for users: set MSAN_OPTIONS=help prior to running a MSAN-instrumented build for options.

Additional info:
Package versions:
* llvm 3.7.0-4
* linux 4.2.3-1

Steps to reproduce:
echo 'int main(){}' | clang -fsanitize=memory -x c - && ./a.out
This task depends upon

Closed by  Evangelos Foutras (foutrelis)
Saturday, 31 October 2015, 12:15 GMT
Reason for closing:  Fixed
Additional comments about closing:  llvm 3.7.0-5
Comment by Evangelos Foutras (foutrelis) - Saturday, 31 October 2015, 12:15 GMT
llvm 3.7.0-5 includes the memory sanitizer patches. The ccc-analyzer patch needs to be committed upstream first (in which case it can wait for 3.8.0).

Loading...