From c11c43b64f31083693ccce6e55ebd69d9990c508 Mon Sep 17 00:00:00 2001 From: Julian Lettner Date: Tue, 9 Jul 2019 20:47:37 +0000 Subject: [PATCH] [TSan] Refine longjmp key management on Darwin NFC. llvm-svn: 365554 --- compiler-rt/lib/tsan/rtl/tsan_platform_mac.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cc b/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cc index e43a9ec..0c2d2aa 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cc @@ -238,8 +238,7 @@ void InitializePlatformEarly() { #endif } -static const uptr kPthreadSetjmpXorKeySlot = 0x7; -extern "C" uptr __tsan_darwin_setjmp_xor_key = 0; +static uptr longjmp_xor_key = 0; void InitializePlatform() { DisableCoreDumperIfNecessary(); @@ -254,8 +253,9 @@ void InitializePlatform() { #endif if (GetMacosVersion() >= MACOS_VERSION_MOJAVE) { - __tsan_darwin_setjmp_xor_key = - (uptr)pthread_getspecific(kPthreadSetjmpXorKeySlot); + // Libsystem currently uses a process-global key; this might change. + const unsigned kTLSLongjmpXorKeySlot = 0x7; + longjmp_xor_key = (uptr)pthread_getspecific(kTLSLongjmpXorKeySlot); } } @@ -268,7 +268,8 @@ void InitializePlatform() { uptr ExtractLongJmpSp(uptr *env) { uptr mangled_sp = env[LONG_JMP_SP_ENV_SLOT]; - return mangled_sp ^ __tsan_darwin_setjmp_xor_key; + uptr sp = mangled_sp ^ longjmp_xor_key; + return sp; } #if !SANITIZER_GO -- 2.7.4