void UnlockThreadRegistry() { __asan::asanThreadRegistry().Unlock(); }
-ThreadRegistry *GetThreadRegistryLocked() {
+static ThreadRegistry *GetAsanThreadRegistryLocked() {
__asan::asanThreadRegistry().CheckLocked();
return &__asan::asanThreadRegistry();
}
fake_stack->ForEachFakeFrame(callback, arg);
}
+void RunCallbackForEachThreadLocked(__sanitizer::ThreadRegistry::ThreadCallback cb,
+ void *arg) {
+ GetAsanThreadRegistryLocked()->RunCallbackForEachThreadLocked(cb, arg);
+}
+
+void FinishThreadLocked(u32 tid) {
+ GetAsanThreadRegistryLocked()->FinishThread(tid);
+}
+
} // namespace __lsan
// ---------------------- Interface ---------------- {{{1
static void ProcessThreadRegistry(Frontier *frontier) {
InternalMmapVector<uptr> ptrs;
- GetThreadRegistryLocked()->RunCallbackForEachThreadLocked(
- GetAdditionalThreadContextPtrs, &ptrs);
+ RunCallbackForEachThreadLocked(GetAdditionalThreadContextPtrs, &ptrs);
for (uptr i = 0; i < ptrs.size(); ++i) {
void *ptr = reinterpret_cast<void *>(ptrs[i]);
Sort(threads.data(), threads.size());
- GetThreadRegistryLocked()->RunCallbackForEachThreadLocked(
- &ReportIfNotSuspended, &threads);
+ RunCallbackForEachThreadLocked(&ReportIfNotSuspended, &threads);
}
# endif // !SANITIZER_FUCHSIA
#include "sanitizer_common/sanitizer_stackdepot.h"
#include "sanitizer_common/sanitizer_stoptheworld.h"
#include "sanitizer_common/sanitizer_symbolizer.h"
+#include "sanitizer_common/sanitizer_thread_registry.h"
// LeakSanitizer relies on some Glibc's internals (e.g. TLS machinery) on Linux.
// Also, LSan doesn't like 32 bit architectures
// Wrappers for ThreadRegistry access.
void LockThreadRegistry() SANITIZER_NO_THREAD_SAFETY_ANALYSIS;
void UnlockThreadRegistry() SANITIZER_NO_THREAD_SAFETY_ANALYSIS;
-ThreadRegistry *GetThreadRegistryLocked();
// If called from the main thread, updates the main thread's TID in the thread
// registry. We need this to handle processes that fork() without a subsequent
// exec(), which invalidates the recorded TID. To update it, we must call
void ForEachExtraStackRange(tid_t os_id, RangeIteratorCallback callback,
void *arg);
+void RunCallbackForEachThreadLocked(__sanitizer::ThreadRegistry::ThreadCallback cb,
+ void *arg);
+void FinishThreadLocked(u32 tid);
+
//// --------------------------------------------------------------------------
//// Allocator prototypes.
//// --------------------------------------------------------------------------
// just for the allocator cache, and to call ForEachExtraStackRange,
// which ASan needs.
if (flags()->use_stacks) {
- GetThreadRegistryLocked()->RunCallbackForEachThreadLocked(
+ RunCallbackForEachThreadLocked(
[](ThreadContextBase *tctx, void *arg) {
ForEachExtraStackRange(tctx->os_id, ForEachExtraStackRangeCb,
arg);
}
void GetAllThreadAllocatorCachesLocked(InternalMmapVector<uptr> *caches) {
- GetThreadRegistryLocked()->RunCallbackForEachThreadLocked(
+ RunCallbackForEachThreadLocked(
[](ThreadContextBase *tctx, void *arg) {
auto ctx = static_cast<ThreadContext *>(tctx);
static_cast<decltype(caches)>(arg)->push_back(ctx->cache_begin());
// On success, there is nothing to do here.
if (error != thrd_success) {
// Clean up the thread registry for the thread creation that didn't happen.
- GetThreadRegistryLocked()->FinishThread(tid);
+ FinishThreadLocked(tid);
}
}
#if SANITIZER_POSIX
#include "lsan.h"
#include "lsan_allocator.h"
+#include "lsan_thread.h"
#include "sanitizer_common/sanitizer_stacktrace.h"
#include "sanitizer_common/sanitizer_tls_get_addr.h"
uptr *tls_begin, uptr *tls_end, uptr *cache_begin,
uptr *cache_end, DTLS **dtls) {
ThreadContext *context = static_cast<ThreadContext *>(
- GetThreadRegistryLocked()->FindThreadContextByOsIDLocked(os_id));
+ GetLsanThreadRegistryLocked()->FindThreadContextByOsIDLocked(os_id));
if (!context)
return false;
*stack_begin = context->stack_begin();
void UnlockThreadRegistry() { thread_registry->Unlock(); }
-ThreadRegistry *GetThreadRegistryLocked() {
+ThreadRegistry *GetLsanThreadRegistryLocked() {
thread_registry->CheckLocked();
return thread_registry;
}
+void RunCallbackForEachThreadLocked(
+ __sanitizer::ThreadRegistry::ThreadCallback cb, void *arg) {
+ GetLsanThreadRegistryLocked()->RunCallbackForEachThreadLocked(cb, arg);
+}
+
+void FinishThreadLocked(u32 tid) {
+ GetLsanThreadRegistryLocked()->FinishThread(tid);
+}
+
} // namespace __lsan
void InitializeThreadRegistry();
void InitializeMainThread();
+ThreadRegistry *GetLsanThreadRegistryLocked();
+
u32 ThreadCreate(u32 tid, bool detached, void *arg = nullptr);
void ThreadFinish();