[PATCH] [asan] Make ASan report the correct thread address ranges to LSan.

Kostya Serebryany kcc at google.com
Tue May 28 01:00:42 PDT 2013


  Please settle the sandbox issues with glider/etc


================
Comment at: lib/asan/lit_tests/unpoison_tls.cc:4
@@ +3,3 @@
+
+// RUN: %clangxx_asan -m64 -O0 %p/SharedLibs/dlclose-test-so.cc \
+// RUN:     -fPIC -shared -o %t-so.so
----------------
this test checks things almost unrelated to optimization level,
so I'd just leave two option sets: O1 for m32/m64

================
Comment at: lib/asan/lit_tests/unpoison_tls.cc:35
@@ +34,3 @@
+
+__thread char tls_var[16];
+
----------------
just in case (for alignment) make it "int64_t tls_var[2]"

================
Comment at: lib/asan/lit_tests/unpoison_tls.cc:47
@@ +46,3 @@
+  assert((void *)tls_var == p_tls_var);
+  tls_var[0] = 1;
+  return 0;
----------------
Theoretically, asan instrumentation module may optimize this access because it sees the TLS global.
(today this does not happen).
I'd make p_tls_var a volatile int64_t pointer and access it instead of tls_var to avoid the optimization. 

================
Comment at: lib/asan/lit_tests/unpoison_tls.cc:58
@@ +57,3 @@
+  assert(res == 0);
+  pthread_create(&p, 0, second, 0);
+  assert(res == 0);
----------------
did you mean 
  res = pthread_create()?

In general, i strongly prefer assert(0 == pthread_create(...)).
Since these tests are never going to be built with -DNDEBUG, this should be fine. 
You may still add #ifndef NDEBUG #error \ "Remove NDEBUG" \ #endif


http://llvm-reviews.chandlerc.com/D862



More information about the llvm-commits mailing list