[llvm-commits] [compiler-rt] r156758 - in /compiler-rt/trunk/lib/tsan/output_tests: mop_with_offset.cc mop_with_offset2.cc

Dmitry Vyukov dvyukov at google.com
Mon May 14 07:00:07 PDT 2012


Author: dvyukov
Date: Mon May 14 09:00:07 2012
New Revision: 156758

URL: http://llvm.org/viewvc/llvm-project?rev=156758&view=rev
Log:
tsan: update output tests to race on heap memory
Races on stack of main thread are problematic for COMPAT mapping, because it's not 1-to-1 and race addr is not properly mapped from shadow back to application memory. 
Update output tests to race heap memory.

Modified:
    compiler-rt/trunk/lib/tsan/output_tests/mop_with_offset.cc
    compiler-rt/trunk/lib/tsan/output_tests/mop_with_offset2.cc

Modified: compiler-rt/trunk/lib/tsan/output_tests/mop_with_offset.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/output_tests/mop_with_offset.cc?rev=156758&r1=156757&r2=156758&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/output_tests/mop_with_offset.cc (original)
+++ compiler-rt/trunk/lib/tsan/output_tests/mop_with_offset.cc Mon May 14 09:00:07 2012
@@ -17,14 +17,15 @@
 }
 
 int main() {
-  int data = 42;
-  fprintf(stderr, "ptr1=%p\n", &data);
-  fprintf(stderr, "ptr2=%p\n", (char*)&data + 2);
+  int *data = new int(42);
+  fprintf(stderr, "ptr1=%p\n", data);
+  fprintf(stderr, "ptr2=%p\n", (char*)data + 2);
   pthread_t t[2];
-  pthread_create(&t[0], NULL, Thread1, &data);
-  pthread_create(&t[1], NULL, Thread2, &data);
+  pthread_create(&t[0], NULL, Thread1, data);
+  pthread_create(&t[1], NULL, Thread2, data);
   pthread_join(t[0], NULL);
   pthread_join(t[1], NULL);
+  delete data;
 }
 
 // CHECK: ptr1=[[PTR1:0x[0-9,a-f]+]]

Modified: compiler-rt/trunk/lib/tsan/output_tests/mop_with_offset2.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/output_tests/mop_with_offset2.cc?rev=156758&r1=156757&r2=156758&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/output_tests/mop_with_offset2.cc (original)
+++ compiler-rt/trunk/lib/tsan/output_tests/mop_with_offset2.cc Mon May 14 09:00:07 2012
@@ -17,14 +17,15 @@
 }
 
 int main() {
-  int data = 42;
-  fprintf(stderr, "ptr1=%p\n", &data);
-  fprintf(stderr, "ptr2=%p\n", (char*)&data + 2);
+  int *data = new int(42);
+  fprintf(stderr, "ptr1=%p\n", data);
+  fprintf(stderr, "ptr2=%p\n", (char*)data + 2);
   pthread_t t[2];
-  pthread_create(&t[0], NULL, Thread1, &data);
-  pthread_create(&t[1], NULL, Thread2, &data);
+  pthread_create(&t[0], NULL, Thread1, data);
+  pthread_create(&t[1], NULL, Thread2, data);
   pthread_join(t[0], NULL);
   pthread_join(t[1], NULL);
+  delete data;
 }
 
 // CHECK: ptr1=[[PTR1:0x[0-9,a-f]+]]





More information about the llvm-commits mailing list