[compiler-rt] r280876 - [asan] Fix a crash in GetCurrentThread() before init.

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 7 15:57:07 PDT 2016


Author: eugenis
Date: Wed Sep  7 17:57:06 2016
New Revision: 280876

URL: http://llvm.org/viewvc/llvm-project?rev=280876&view=rev
Log:
[asan] Fix a crash in GetCurrentThread() before init.

Android-specific code in GetCurrentThread() does not handle the situation when there is no
ThreadContext for the current thread. This happens if the current thread is requested before the
main thread is added to the registry. 64-bit allocator does that to record map/unmap stats during
initialization.

Modified:
    compiler-rt/trunk/lib/asan/asan_thread.cc

Modified: compiler-rt/trunk/lib/asan/asan_thread.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_thread.cc?rev=280876&r1=280875&r2=280876&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_thread.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_thread.cc Wed Sep  7 17:57:06 2016
@@ -345,7 +345,7 @@ AsanThread *GetCurrentThread() {
       // limits, so only do this magic on Android, and only if the found thread
       // is the main thread.
       AsanThreadContext *tctx = GetThreadContextByTidLocked(0);
-      if (ThreadStackContainsAddress(tctx, &context)) {
+      if (tctx && ThreadStackContainsAddress(tctx, &context)) {
         SetCurrentThread(tctx->thread);
         return tctx->thread;
       }




More information about the llvm-commits mailing list