[PATCH] D46650: [lsan] Try to fix test failure due to compiler optimization
Peter Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 9 10:39:11 PDT 2018
Lekensteyn created this revision.
Lekensteyn added reviewers: m.ostapenko, rengolin, kcc.
Lekensteyn added a project: Sanitizers.
Herald added subscribers: Sanitizers, llvm-commits, kubamracek.
Fix SanitizerCommon-lsan-x86_64-Linux test failure by cleaning the
stack. The issue was only present with optimization enabled, building
the whole test with -O0 did not trigger any issue.
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D46650
Files:
test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc
Index: test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc
===================================================================
--- test/sanitizer_common/TestCases/Posix/sanitizer_set_death_callback_test.cc
+++ 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>
@@ -34,6 +28,13 @@
sink = new char[100]; // trigger lsan report.
}
+// Ensure stack memory is erased, otherwise the sink pointer passed to
+// "delete[]" might be left on the stack.
+__attribute__((noinline, optnone))
+void ClearStackMemory(char *dummy_for_x86) {
+ void *stack[100] = {0};
+}
+
int main(int argc, char **argv) {
int uninitialized;
__sanitizer_set_death_callback(Death);
@@ -45,4 +46,5 @@
global = sink[0]; // use-after-free: trigger asan/tsan report.
Leak();
sink = 0;
+ ClearStackMemory(0);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46650.145955.patch
Type: text/x-patch
Size: 1377 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180509/0cd1e71e/attachment.bin>
More information about the llvm-commits
mailing list