blob: 69813546f551cc0336a24e5fd331e01896abed20 [file] [log] [blame]
Alexey Samsonove5f58952012-06-04 13:50:10 +00001//===-- asan_thread.cc ----------------------------------------------------===//
Kostya Serebryany1e172b42011-11-30 01:07:02 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file is a part of AddressSanitizer, an address sanity checker.
11//
12// Thread-related code.
13//===----------------------------------------------------------------------===//
14#include "asan_allocator.h"
15#include "asan_interceptors.h"
Alexey Samsonov7e843492013-03-28 15:42:43 +000016#include "asan_poisoning.h"
Alexey Samsonov55cdfc62012-01-17 06:35:31 +000017#include "asan_stack.h"
Kostya Serebryany1e172b42011-11-30 01:07:02 +000018#include "asan_thread.h"
Kostya Serebryany1e172b42011-11-30 01:07:02 +000019#include "asan_mapping.h"
Alexey Samsonove5931fd2012-06-07 07:13:46 +000020#include "sanitizer_common/sanitizer_common.h"
Alexey Samsonovdef1be92013-03-21 11:23:41 +000021#include "sanitizer_common/sanitizer_placement_new.h"
Kostya Serebryany6d958692013-10-18 14:50:44 +000022#include "sanitizer_common/sanitizer_stackdepot.h"
Stephen Hines2d1fdb22014-05-28 23:58:16 -070023#include "sanitizer_common/sanitizer_tls_get_addr.h"
Sergey Matveevf1ac1a42013-05-21 13:40:13 +000024#include "lsan/lsan_common.h"
Kostya Serebryany1e172b42011-11-30 01:07:02 +000025
Kostya Serebryany1e172b42011-11-30 01:07:02 +000026namespace __asan {
27
Alexey Samsonovdef1be92013-03-21 11:23:41 +000028// AsanThreadContext implementation.
Kostya Serebryany1e172b42011-11-30 01:07:02 +000029
Stephen Hines86277eb2015-03-23 12:06:32 -070030struct CreateThreadContextArgs {
31 AsanThread *thread;
32 StackTrace *stack;
33};
34
Alexey Samsonovdef1be92013-03-21 11:23:41 +000035void AsanThreadContext::OnCreated(void *arg) {
36 CreateThreadContextArgs *args = static_cast<CreateThreadContextArgs*>(arg);
Kostya Serebryany6d958692013-10-18 14:50:44 +000037 if (args->stack)
Stephen Hines6d186232014-11-26 17:56:19 -080038 stack_id = StackDepotPut(*args->stack);
Alexey Samsonovdef1be92013-03-21 11:23:41 +000039 thread = args->thread;
40 thread->set_context(this);
41}
42
43void AsanThreadContext::OnFinished() {
44 // Drop the link to the AsanThread object.
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080045 thread = nullptr;
Alexey Samsonovdef1be92013-03-21 11:23:41 +000046}
47
Kostya Serebryany40527a52013-06-03 14:49:25 +000048// MIPS requires aligned address
Timur Iskhodzhanov7c9ffde2013-06-04 08:25:17 +000049static ALIGNED(16) char thread_registry_placeholder[sizeof(ThreadRegistry)];
Alexey Samsonovdef1be92013-03-21 11:23:41 +000050static ThreadRegistry *asan_thread_registry;
51
Kostya Serebryany1fe68b82013-10-18 15:07:07 +000052static BlockingMutex mu_for_thread_context(LINKER_INITIALIZED);
53static LowLevelAllocator allocator_for_thread_context;
54
Alexey Samsonovdef1be92013-03-21 11:23:41 +000055static ThreadContextBase *GetAsanThreadContext(u32 tid) {
Kostya Serebryany1fe68b82013-10-18 15:07:07 +000056 BlockingMutexLock lock(&mu_for_thread_context);
Peter Collingbourne53177242013-10-24 06:23:39 +000057 return new(allocator_for_thread_context) AsanThreadContext(tid);
Alexey Samsonovdef1be92013-03-21 11:23:41 +000058}
59
60ThreadRegistry &asanThreadRegistry() {
61 static bool initialized;
62 // Don't worry about thread_safety - this should be called when there is
63 // a single thread.
64 if (!initialized) {
65 // Never reuse ASan threads: we store pointer to AsanThreadContext
66 // in TSD and can't reliably tell when no more TSD destructors will
67 // be called. It would be wrong to reuse AsanThreadContext for another
68 // thread before all TSD destructors will be called for it.
69 asan_thread_registry = new(thread_registry_placeholder) ThreadRegistry(
70 GetAsanThreadContext, kMaxNumberOfThreads, kMaxNumberOfThreads);
71 initialized = true;
72 }
73 return *asan_thread_registry;
74}
75
76AsanThreadContext *GetThreadContextByTidLocked(u32 tid) {
77 return static_cast<AsanThreadContext *>(
78 asanThreadRegistry().GetThreadLocked(tid));
79}
80
81// AsanThread implementation.
82
Stephen Hines86277eb2015-03-23 12:06:32 -070083AsanThread *AsanThread::Create(thread_callback_t start_routine, void *arg,
84 u32 parent_tid, StackTrace *stack,
85 bool detached) {
Kostya Serebryanyf67ec2b2012-11-23 15:38:49 +000086 uptr PageSize = GetPageSizeCached();
87 uptr size = RoundUpTo(sizeof(AsanThread), PageSize);
Stephen Hines2d1fdb22014-05-28 23:58:16 -070088 AsanThread *thread = (AsanThread*)MmapOrDie(size, __func__);
Alexey Samsonov55cdfc62012-01-17 06:35:31 +000089 thread->start_routine_ = start_routine;
90 thread->arg_ = arg;
Stephen Hines86277eb2015-03-23 12:06:32 -070091 CreateThreadContextArgs args = { thread, stack };
92 asanThreadRegistry().CreateThread(*reinterpret_cast<uptr *>(thread), detached,
93 parent_tid, &args);
Alexey Samsonov55cdfc62012-01-17 06:35:31 +000094
95 return thread;
Kostya Serebryany1e172b42011-11-30 01:07:02 +000096}
97
Alexey Samsonovdef1be92013-03-21 11:23:41 +000098void AsanThread::TSDDtor(void *tsd) {
99 AsanThreadContext *context = (AsanThreadContext*)tsd;
Stephen Hines2d1fdb22014-05-28 23:58:16 -0700100 VReport(1, "T%d TSDDtor\n", context->tid);
Alexey Samsonovdef1be92013-03-21 11:23:41 +0000101 if (context->thread)
102 context->thread->Destroy();
Kostya Serebryanyf58f9982012-02-07 00:27:15 +0000103}
104
Kostya Serebryanya6b52262012-01-06 19:44:11 +0000105void AsanThread::Destroy() {
Stephen Hines2d1fdb22014-05-28 23:58:16 -0700106 int tid = this->tid();
107 VReport(1, "T%d exited\n", tid);
Kostya Serebryanyf58f9982012-02-07 00:27:15 +0000108
Kostya Serebryanyae914e22013-11-13 13:27:44 +0000109 malloc_storage().CommitBack();
Stephen Hines2d1fdb22014-05-28 23:58:16 -0700110 if (common_flags()->use_sigaltstack) UnsetAlternateSignalStack();
111 asanThreadRegistry().FinishThread(tid);
Alexey Samsonov717ece52013-09-02 08:39:07 +0000112 FlushToDeadThreadStats(&stats_);
Kostya Serebryany1e172b42011-11-30 01:07:02 +0000113 // We also clear the shadow on thread destruction because
114 // some code may still be executing in later TSD destructors
115 // and we don't want it to have any poisoned stack.
Sergey Matveev12d01ba2013-05-29 13:09:44 +0000116 ClearShadowForThreadStackAndTLS();
Stephen Hines2d1fdb22014-05-28 23:58:16 -0700117 DeleteFakeStack(tid);
Kostya Serebryanyf67ec2b2012-11-23 15:38:49 +0000118 uptr size = RoundUpTo(sizeof(AsanThread), GetPageSizeCached());
Alexey Samsonova25b3462012-06-06 16:15:07 +0000119 UnmapOrDie(this, size);
Stephen Hines2d1fdb22014-05-28 23:58:16 -0700120 DTLS_Destroy();
Kostya Serebryany1e172b42011-11-30 01:07:02 +0000121}
122
Kostya Serebryanyc98fc1f2013-09-12 08:34:50 +0000123// We want to create the FakeStack lazyly on the first use, but not eralier
124// than the stack size is known and the procedure has to be async-signal safe.
125FakeStack *AsanThread::AsyncSignalSafeLazyInitFakeStack() {
126 uptr stack_size = this->stack_size();
127 if (stack_size == 0) // stack_size is not yet available, don't use FakeStack.
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -0800128 return nullptr;
Kostya Serebryanyc98fc1f2013-09-12 08:34:50 +0000129 uptr old_val = 0;
130 // fake_stack_ has 3 states:
131 // 0 -- not initialized
132 // 1 -- being initialized
133 // ptr -- initialized
134 // This CAS checks if the state was 0 and if so changes it to state 1,
Stephen Hines2d1fdb22014-05-28 23:58:16 -0700135 // if that was successful, it initializes the pointer.
Kostya Serebryanyc98fc1f2013-09-12 08:34:50 +0000136 if (atomic_compare_exchange_strong(
137 reinterpret_cast<atomic_uintptr_t *>(&fake_stack_), &old_val, 1UL,
Kostya Serebryany9433af32013-09-13 06:32:26 +0000138 memory_order_relaxed)) {
Kostya Serebryany230e52f2013-09-18 10:35:12 +0000139 uptr stack_size_log = Log2(RoundUpToPowerOfTwo(stack_size));
Stephen Hines2d1fdb22014-05-28 23:58:16 -0700140 CHECK_LE(flags()->min_uar_stack_size_log, flags()->max_uar_stack_size_log);
141 stack_size_log =
142 Min(stack_size_log, static_cast<uptr>(flags()->max_uar_stack_size_log));
143 stack_size_log =
144 Max(stack_size_log, static_cast<uptr>(flags()->min_uar_stack_size_log));
Kostya Serebryany230e52f2013-09-18 10:35:12 +0000145 fake_stack_ = FakeStack::Create(stack_size_log);
Kostya Serebryany9433af32013-09-13 06:32:26 +0000146 SetTLSFakeStack(fake_stack_);
147 return fake_stack_;
148 }
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -0800149 return nullptr;
Kostya Serebryanyc98fc1f2013-09-12 08:34:50 +0000150}
151
Kostya Serebryany69eca732011-12-16 19:13:35 +0000152void AsanThread::Init() {
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -0800153 fake_stack_ = nullptr; // Will be initialized lazily if needed.
Stephen Hines6a211c52014-07-21 00:49:56 -0700154 CHECK_EQ(this->stack_size(), 0U);
Sergey Matveev12d01ba2013-05-29 13:09:44 +0000155 SetThreadStackAndTls();
Stephen Hines6a211c52014-07-21 00:49:56 -0700156 CHECK_GT(this->stack_size(), 0U);
Alexey Samsonov55cdfc62012-01-17 06:35:31 +0000157 CHECK(AddrIsInMem(stack_bottom_));
Kostya Serebryany541cfb12013-01-18 11:30:36 +0000158 CHECK(AddrIsInMem(stack_top_ - 1));
Sergey Matveev12d01ba2013-05-29 13:09:44 +0000159 ClearShadowForThreadStackAndTLS();
Stephen Hines2d1fdb22014-05-28 23:58:16 -0700160 int local = 0;
161 VReport(1, "T%d: stack [%p,%p) size 0x%zx; local=%p\n", tid(),
162 (void *)stack_bottom_, (void *)stack_top_, stack_top_ - stack_bottom_,
163 &local);
Kostya Serebryany69eca732011-12-16 19:13:35 +0000164}
165
Stephen Hines86277eb2015-03-23 12:06:32 -0700166thread_return_t AsanThread::ThreadStart(
167 uptr os_id, atomic_uintptr_t *signal_thread_is_registered) {
Kostya Serebryany69eca732011-12-16 19:13:35 +0000168 Init();
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -0800169 asanThreadRegistry().StartThread(tid(), os_id, nullptr);
Stephen Hines86277eb2015-03-23 12:06:32 -0700170 if (signal_thread_is_registered)
171 atomic_store(signal_thread_is_registered, 1, memory_order_release);
172
Stephen Hines2d1fdb22014-05-28 23:58:16 -0700173 if (common_flags()->use_sigaltstack) SetAlternateSignalStack();
Kostya Serebryany1e172b42011-11-30 01:07:02 +0000174
175 if (!start_routine_) {
Kostya Serebryany3f4c3872012-05-31 14:35:53 +0000176 // start_routine_ == 0 if we're on the main thread or on one of the
Kostya Serebryany1e172b42011-11-30 01:07:02 +0000177 // OS X libdispatch worker threads. But nobody is supposed to call
178 // ThreadStart() for the worker threads.
Kostya Serebryanya27bdf72013-04-05 14:40:25 +0000179 CHECK_EQ(tid(), 0);
Kostya Serebryany1e172b42011-11-30 01:07:02 +0000180 return 0;
181 }
182
Timur Iskhodzhanov600972e2012-02-24 15:28:43 +0000183 thread_return_t res = start_routine_(arg_);
Kostya Serebryany1e172b42011-11-30 01:07:02 +0000184
Sergey Matveeve86e35f2013-10-14 12:01:05 +0000185 // On POSIX systems we defer this to the TSD destructor. LSan will consider
186 // the thread's memory as non-live from the moment we call Destroy(), even
187 // though that memory might contain pointers to heap objects which will be
188 // cleaned up by a user-defined TSD destructor. Thus, calling Destroy() before
189 // the TSD destructors have run might cause false positives in LSan.
190 if (!SANITIZER_POSIX)
191 this->Destroy();
Kostya Serebryanyaf344152012-01-11 02:03:16 +0000192
Kostya Serebryany1e172b42011-11-30 01:07:02 +0000193 return res;
194}
195
Sergey Matveev12d01ba2013-05-29 13:09:44 +0000196void AsanThread::SetThreadStackAndTls() {
Kostya Serebryany621770a2013-09-19 14:59:52 +0000197 uptr tls_size = 0;
198 GetThreadStackAndTls(tid() == 0, &stack_bottom_, &stack_size_, &tls_begin_,
Sergey Matveev12d01ba2013-05-29 13:09:44 +0000199 &tls_size);
Kostya Serebryany621770a2013-09-19 14:59:52 +0000200 stack_top_ = stack_bottom_ + stack_size_;
Sergey Matveev12d01ba2013-05-29 13:09:44 +0000201 tls_end_ = tls_begin_ + tls_size;
202
Alexey Samsonove5931fd2012-06-07 07:13:46 +0000203 int local;
204 CHECK(AddrIsInStack((uptr)&local));
205}
206
Sergey Matveev12d01ba2013-05-29 13:09:44 +0000207void AsanThread::ClearShadowForThreadStackAndTLS() {
Alexey Samsonov55cdfc62012-01-17 06:35:31 +0000208 PoisonShadow(stack_bottom_, stack_top_ - stack_bottom_, 0);
Sergey Matveev12d01ba2013-05-29 13:09:44 +0000209 if (tls_begin_ != tls_end_)
210 PoisonShadow(tls_begin_, tls_end_ - tls_begin_, 0);
Alexey Samsonov55cdfc62012-01-17 06:35:31 +0000211}
212
Stephen Hines6d186232014-11-26 17:56:19 -0800213bool AsanThread::GetStackFrameAccessByAddr(uptr addr,
214 StackFrameAccess *access) {
Kostya Serebryany3f4c3872012-05-31 14:35:53 +0000215 uptr bottom = 0;
Kostya Serebryany1e172b42011-11-30 01:07:02 +0000216 if (AddrIsInStack(addr)) {
217 bottom = stack_bottom();
Kostya Serebryanydcf98bf2013-09-12 08:43:44 +0000218 } else if (has_fake_stack()) {
Kostya Serebryany7a0bba42013-06-26 12:16:05 +0000219 bottom = fake_stack()->AddrIsInFakeStack(addr);
Kostya Serebryany1e172b42011-11-30 01:07:02 +0000220 CHECK(bottom);
Stephen Hines6d186232014-11-26 17:56:19 -0800221 access->offset = addr - bottom;
222 access->frame_pc = ((uptr*)bottom)[2];
223 access->frame_descr = (const char *)((uptr*)bottom)[1];
224 return true;
Kostya Serebryany1e172b42011-11-30 01:07:02 +0000225 }
Kostya Serebryany5af39e52012-11-21 12:38:58 +0000226 uptr aligned_addr = addr & ~(SANITIZER_WORDSIZE/8 - 1); // align addr.
Kostya Serebryanyee392552012-05-31 15:02:07 +0000227 u8 *shadow_ptr = (u8*)MemToShadow(aligned_addr);
228 u8 *shadow_bottom = (u8*)MemToShadow(bottom);
Evgeniy Stepanov3972ea02012-05-12 12:33:10 +0000229
230 while (shadow_ptr >= shadow_bottom &&
Alexander Potapenkoe406c8c2012-11-15 15:24:42 +0000231 *shadow_ptr != kAsanStackLeftRedzoneMagic) {
Evgeniy Stepanov3972ea02012-05-12 12:33:10 +0000232 shadow_ptr--;
Kostya Serebryany1e172b42011-11-30 01:07:02 +0000233 }
Evgeniy Stepanov3972ea02012-05-12 12:33:10 +0000234
235 while (shadow_ptr >= shadow_bottom &&
Alexander Potapenkoe406c8c2012-11-15 15:24:42 +0000236 *shadow_ptr == kAsanStackLeftRedzoneMagic) {
Evgeniy Stepanov3972ea02012-05-12 12:33:10 +0000237 shadow_ptr--;
238 }
239
240 if (shadow_ptr < shadow_bottom) {
Stephen Hines6d186232014-11-26 17:56:19 -0800241 return false;
Evgeniy Stepanov3972ea02012-05-12 12:33:10 +0000242 }
243
Kostya Serebryany3f4c3872012-05-31 14:35:53 +0000244 uptr* ptr = (uptr*)SHADOW_TO_MEM((uptr)(shadow_ptr + 1));
Alexander Potapenkoe406c8c2012-11-15 15:24:42 +0000245 CHECK(ptr[0] == kCurrentStackFrameMagic);
Stephen Hines6d186232014-11-26 17:56:19 -0800246 access->offset = addr - (uptr)ptr;
247 access->frame_pc = ptr[2];
248 access->frame_descr = (const char*)ptr[1];
249 return true;
Kostya Serebryany1e172b42011-11-30 01:07:02 +0000250}
251
Alexey Samsonovdef1be92013-03-21 11:23:41 +0000252static bool ThreadStackContainsAddress(ThreadContextBase *tctx_base,
253 void *addr) {
254 AsanThreadContext *tctx = static_cast<AsanThreadContext*>(tctx_base);
255 AsanThread *t = tctx->thread;
Kostya Serebryany7a0bba42013-06-26 12:16:05 +0000256 if (!t) return false;
257 if (t->AddrIsInStack((uptr)addr)) return true;
Kostya Serebryanyb39a6042013-09-12 08:47:00 +0000258 if (t->has_fake_stack() && t->fake_stack()->AddrIsInFakeStack((uptr)addr))
Kostya Serebryany7a0bba42013-06-26 12:16:05 +0000259 return true;
260 return false;
Alexey Samsonovdef1be92013-03-21 11:23:41 +0000261}
262
Alexey Samsonov89c13842013-03-20 09:23:28 +0000263AsanThread *GetCurrentThread() {
Sergey Matveevc6ac98d2013-07-08 12:57:24 +0000264 AsanThreadContext *context =
265 reinterpret_cast<AsanThreadContext *>(AsanTSDGet());
Alexey Samsonovdef1be92013-03-21 11:23:41 +0000266 if (!context) {
267 if (SANITIZER_ANDROID) {
268 // On Android, libc constructor is called _after_ asan_init, and cleans up
269 // TSD. Try to figure out if this is still the main thread by the stack
270 // address. We are not entirely sure that we have correct main thread
Dmitry Vyukov195369b2013-03-22 07:29:59 +0000271 // limits, so only do this magic on Android, and only if the found thread
272 // is the main thread.
Alexey Samsonovdef1be92013-03-21 11:23:41 +0000273 AsanThreadContext *tctx = GetThreadContextByTidLocked(0);
274 if (ThreadStackContainsAddress(tctx, &context)) {
275 SetCurrentThread(tctx->thread);
276 return tctx->thread;
277 }
Alexey Samsonov89c13842013-03-20 09:23:28 +0000278 }
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -0800279 return nullptr;
Alexey Samsonov89c13842013-03-20 09:23:28 +0000280 }
Alexey Samsonovdef1be92013-03-21 11:23:41 +0000281 return context->thread;
Alexey Samsonov89c13842013-03-20 09:23:28 +0000282}
283
284void SetCurrentThread(AsanThread *t) {
Alexey Samsonovdef1be92013-03-21 11:23:41 +0000285 CHECK(t->context());
Stephen Hines2d1fdb22014-05-28 23:58:16 -0700286 VReport(2, "SetCurrentThread: %p for thread %p\n", t->context(),
287 (void *)GetThreadSelf());
Alexey Samsonov89c13842013-03-20 09:23:28 +0000288 // Make sure we do not reset the current AsanThread.
Alexey Samsonovdef1be92013-03-21 11:23:41 +0000289 CHECK_EQ(0, AsanTSDGet());
290 AsanTSDSet(t->context());
291 CHECK_EQ(t->context(), AsanTSDGet());
Alexey Samsonov89c13842013-03-20 09:23:28 +0000292}
293
294u32 GetCurrentTidOrInvalid() {
295 AsanThread *t = GetCurrentThread();
296 return t ? t->tid() : kInvalidTid;
297}
298
Alexey Samsonovdef1be92013-03-21 11:23:41 +0000299AsanThread *FindThreadByStackAddress(uptr addr) {
300 asanThreadRegistry().CheckLocked();
301 AsanThreadContext *tctx = static_cast<AsanThreadContext *>(
302 asanThreadRegistry().FindThreadContextLocked(ThreadStackContainsAddress,
303 (void *)addr));
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -0800304 return tctx ? tctx->thread : nullptr;
Alexey Samsonovdef1be92013-03-21 11:23:41 +0000305}
Sergey Matveevc6ac98d2013-07-08 12:57:24 +0000306
307void EnsureMainThreadIDIsCorrect() {
308 AsanThreadContext *context =
309 reinterpret_cast<AsanThreadContext *>(AsanTSDGet());
310 if (context && (context->tid == 0))
311 context->os_id = GetTid();
312}
Sergey Matveevc5193352013-10-14 14:04:50 +0000313
314__asan::AsanThread *GetAsanThreadByOsIDLocked(uptr os_id) {
315 __asan::AsanThreadContext *context = static_cast<__asan::AsanThreadContext *>(
316 __asan::asanThreadRegistry().FindThreadContextByOsIDLocked(os_id));
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -0800317 if (!context) return nullptr;
Sergey Matveevc5193352013-10-14 14:04:50 +0000318 return context->thread;
319}
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -0800320} // namespace __asan
Sergey Matveevf1ac1a42013-05-21 13:40:13 +0000321
322// --- Implementation of LSan-specific functions --- {{{1
323namespace __lsan {
324bool GetThreadRangesLocked(uptr os_id, uptr *stack_begin, uptr *stack_end,
325 uptr *tls_begin, uptr *tls_end,
326 uptr *cache_begin, uptr *cache_end) {
Sergey Matveevc5193352013-10-14 14:04:50 +0000327 __asan::AsanThread *t = __asan::GetAsanThreadByOsIDLocked(os_id);
Sergey Matveev12d01ba2013-05-29 13:09:44 +0000328 if (!t) return false;
329 *stack_begin = t->stack_bottom();
330 *stack_end = t->stack_top();
331 *tls_begin = t->tls_begin();
332 *tls_end = t->tls_end();
333 // ASan doesn't keep allocator caches in TLS, so these are unused.
334 *cache_begin = 0;
335 *cache_end = 0;
336 return true;
Sergey Matveevf1ac1a42013-05-21 13:40:13 +0000337}
338
Sergey Matveevc5193352013-10-14 14:04:50 +0000339void ForEachExtraStackRange(uptr os_id, RangeIteratorCallback callback,
340 void *arg) {
341 __asan::AsanThread *t = __asan::GetAsanThreadByOsIDLocked(os_id);
342 if (t && t->has_fake_stack())
343 t->fake_stack()->ForEachFakeFrame(callback, arg);
344}
345
Sergey Matveevf1ac1a42013-05-21 13:40:13 +0000346void LockThreadRegistry() {
347 __asan::asanThreadRegistry().Lock();
348}
349
350void UnlockThreadRegistry() {
351 __asan::asanThreadRegistry().Unlock();
352}
Sergey Matveevc6ac98d2013-07-08 12:57:24 +0000353
354void EnsureMainThreadIDIsCorrect() {
355 __asan::EnsureMainThreadIDIsCorrect();
356}
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -0800357} // namespace __lsan