Skip to content

Commit

Permalink
Avoid use of lsan::GetCurrentThread in lsan_common_emscripten.cpp
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sbc100 committed Jan 21, 2024
1 parent 0df6362 commit 646a905
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
2 changes: 0 additions & 2 deletions system/lib/compiler-rt/lib/asan/asan_emscripten.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ void GetAllocatorCacheRange(uptr *begin, uptr *end) {
}
#endif

u32 GetCurrentThread() { return __asan::GetCurrentThread()->tid(); }

} // namespace __lsan

#endif // SANITIZER_EMSCRIPTEN
4 changes: 1 addition & 3 deletions system/lib/compiler-rt/lib/lsan/lsan_common_emscripten.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 646a905

Please sign in to comment.