summaryrefslogtreecommitdiff
path: root/test/sanitizer_common
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2018-05-10 19:02:32 +0000
committerPeter Wu <peter@lekensteyn.nl>2018-05-10 19:02:32 +0000
commit15ab700107a67e2edf5470b34fe8d4f72a9b0d71 (patch)
treeb221eb19ad9d0b5990c6d2349ca9a9c812f47cdb /test/sanitizer_common
parent26039149afebd2388fbc453ebc04d496ce126310 (diff)
[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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@332020 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/sanitizer_common')
-rw-r--r--test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc11
1 files changed, 4 insertions, 7 deletions
diff --git a/test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc b/test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc
index 8d2db3641..54272b017 100644
--- a/test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc
+++ b/test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc
@@ -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) {