From 4ca8ee692e1def1b9ebbebf823a4e294277b724a Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 21 Nov 2013 11:48:29 +0000 Subject: [PATCH] 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 llvm-svn: 195345 --- compiler-rt/lib/tsan/rtl/tsan_interceptors.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc index ef38f7987cde..e38f157e401a 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc @@ -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);