[compiler-rt] r218069 - tsan: fix signal_longjmp test in debug mode
Dmitry Vyukov
dvyukov at google.com
Thu Sep 18 12:00:03 PDT 2014
Author: dvyukov
Date: Thu Sep 18 14:00:02 2014
New Revision: 218069
URL: http://llvm.org/viewvc/llvm-project?rev=218069&view=rev
Log:
tsan: fix signal_longjmp test in debug mode
In debug mode tsan checks that user accesses
access user memory. NULL is not user memory.
So the test fails. Allocate real inaccessible
memory for the test.
Modified:
compiler-rt/trunk/test/tsan/signal_longjmp.cc
Modified: compiler-rt/trunk/test/tsan/signal_longjmp.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/signal_longjmp.cc?rev=218069&r1=218068&r2=218069&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/signal_longjmp.cc (original)
+++ compiler-rt/trunk/test/tsan/signal_longjmp.cc Thu Sep 18 14:00:02 2014
@@ -7,6 +7,7 @@
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
+#include <sys/mman.h>
sigjmp_buf fault_jmp;
volatile int fault_expected;
@@ -45,9 +46,12 @@ int main() {
exit(1);
}
- MUST_FAULT(((volatile int *volatile)0)[0] = 0);
- MUST_FAULT(((volatile int *volatile)0)[1] = 1);
- MUST_FAULT(((volatile int *volatile)0)[3] = 1);
+ void *mem = mmap(0, 4096, PROT_NONE, MAP_PRIVATE | MAP_ANON,
+ -1, 0);
+
+ MUST_FAULT(((volatile int *volatile)mem)[0] = 0);
+ MUST_FAULT(((volatile int *volatile)mem)[1] = 1);
+ MUST_FAULT(((volatile int *volatile)mem)[3] = 1);
// Ensure that tsan does not think that we are
// in a signal handler.
@@ -55,6 +59,8 @@ int main() {
((volatile int*)p)[1] = 1;
free((void*)p);
+ munmap(p, 4096);
+
fprintf(stderr, "DONE\n");
return 0;
}
More information about the llvm-commits
mailing list