[compiler-rt] r195345 - tsan: fix handling of setjmp

Dmitry Vyukov dvyukov at google.com
Thu Nov 21 03:48:29 PST 2013


Author: dvyukov
Date: Thu Nov 21 05:48:29 2013
New Revision: 195345

URL: http://llvm.org/viewvc/llvm-project?rev=195345&view=rev
Log:
tsan: fix handling of setjmp

It's incorrect to take address of setjmp,
because it may not (ligally) present in libc.
Fixes http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59188


Modified:
    compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc?rev=195345&r1=195344&r2=195345&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc Thu Nov 21 05:48:29 2013
@@ -2048,10 +2048,14 @@ void InitializeInterceptors() {
 
   SANITIZER_COMMON_INTERCEPTORS_INIT;
 
-  TSAN_INTERCEPT(setjmp);
-  TSAN_INTERCEPT(_setjmp);
-  TSAN_INTERCEPT(sigsetjmp);
-  TSAN_INTERCEPT(__sigsetjmp);
+  // We can not use TSAN_INTERCEPT to get setjmp addr,
+  // because it does &setjmp and setjmp is not present in some versions of libc.
+  using __interception::GetRealFunctionAddress;
+  GetRealFunctionAddress("setjmp", (uptr*)&REAL(setjmp), 0, 0);
+  GetRealFunctionAddress("_setjmp", (uptr*)&REAL(_setjmp), 0, 0);
+  GetRealFunctionAddress("sigsetjmp", (uptr*)&REAL(sigsetjmp), 0, 0);
+  GetRealFunctionAddress("__sigsetjmp", (uptr*)&REAL(__sigsetjmp), 0, 0);
+
   TSAN_INTERCEPT(longjmp);
   TSAN_INTERCEPT(siglongjmp);
 





More information about the llvm-commits mailing list