From 646a9057887ef7507f803d1c3e189e7ccd9cd26b Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Sun, 21 Jan 2024 23:25:44 +0000 Subject: [PATCH] Avoid use of `lsan::GetCurrentThread` in `lsan_common_emscripten.cpp` This code was depending in a dummy version of `lsan::GetCurrentThread` that was added to `asan_emscripten.cpp`. However as far as I can tell this never worked since the dummy version of `lsan::GetCurrentThread` was returning a TID directly, but its expected to return a pointer. --- system/lib/compiler-rt/lib/asan/asan_emscripten.cpp | 2 -- system/lib/compiler-rt/lib/lsan/lsan_common_emscripten.cpp | 4 +--- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/system/lib/compiler-rt/lib/asan/asan_emscripten.cpp b/system/lib/compiler-rt/lib/asan/asan_emscripten.cpp index 90b3c5bbae8ee..59457db3a8252 100644 --- a/system/lib/compiler-rt/lib/asan/asan_emscripten.cpp +++ b/system/lib/compiler-rt/lib/asan/asan_emscripten.cpp @@ -109,8 +109,6 @@ void GetAllocatorCacheRange(uptr *begin, uptr *end) { } #endif -u32 GetCurrentThread() { return __asan::GetCurrentThread()->tid(); } - } // namespace __lsan #endif // SANITIZER_EMSCRIPTEN diff --git a/system/lib/compiler-rt/lib/lsan/lsan_common_emscripten.cpp b/system/lib/compiler-rt/lib/lsan/lsan_common_emscripten.cpp index 2407842cb5828..46bfedb9b519b 100644 --- a/system/lib/compiler-rt/lib/lsan/lsan_common_emscripten.cpp +++ b/system/lib/compiler-rt/lib/lsan/lsan_common_emscripten.cpp @@ -112,8 +112,6 @@ void LockStuffAndStopTheWorld(StopTheWorldCallback callback, UnlockThreads(); } -u32 GetCurrentThreadId(); - // This is based on ProcessThreads in lsan_common.cc. // We changed this to be a callback that gets called per thread by // ThreadRegistry::RunCallbackForEachThreadLocked. @@ -142,7 +140,7 @@ static void ProcessThreadsCallback(ThreadContextBase *tctx, void *arg) { // We can't get the SP for other threads to narrow down the range, but we // we can for the current thread. - if (tctx->tid == GetCurrentThreadId()) { + if (tctx->os_id == GetTid()) { uptr sp = (uptr) __builtin_frame_address(0); if (sp < stack_begin || sp >= stack_end) { // SP is outside the recorded stack range (e.g. the thread is running a