[compiler-rt] r332020 - [lsan] Try to fix test failure due to compiler optimization

Peter Wu via llvm-commits llvm-commits at lists.llvm.org
Thu May 10 12:02:32 PDT 2018


Author: lekensteyn
Date: Thu May 10 12:02:32 2018
New Revision: 332020

URL: http://llvm.org/viewvc/llvm-project?rev=332020&view=rev
Log:
[lsan] Try to fix test failure due to compiler optimization

Summary:
The SanitizerCommon-lsan-x86_64-Linux test failed due to the address of
the very first allocation ending up in the stack through "delete[]".
Workaround this by performing another allocation. The issue was only
present with optimization enabled, the test would pass with -O0.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D46650

Modified:
    compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc?rev=332020&r1=332019&r2=332020&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc Thu May 10 12:02:32 2018
@@ -2,12 +2,6 @@
 
 // REQUIRES: stable-runtime
 
-// For standalone LSan on x86 we have a problem: compiler spills the address
-// of allocated at line 42 memory thus memory block allocated in Leak() function
-// ends up to be classified as reachable despite the fact we zero out 'sink' at
-// the last line of main function. The problem doesn't reproduce with ASan because
-// quarantine prohibits memory block reuse for different allocations.
-// XFAIL: lsan-x86
 // XFAIL: ubsan
 
 #include <sanitizer/common_interface_defs.h>
@@ -31,7 +25,10 @@ void MaybeInit(int *uninitialized) {
 
 __attribute__((noinline))
 void Leak() {
-  sink = new char[100];  // trigger lsan report.
+  // Trigger lsan report. Two attempts in case the address of the first
+  // allocation remained on the stack.
+  sink = new char[100];
+  sink = new char[100];
 }
 
 int main(int argc, char **argv) {




More information about the llvm-commits mailing list