diff options
author | Christopher Ferris <cferris@google.com> | 2017-09-18 14:39:33 -0700 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2017-09-18 17:20:08 -0700 |
commit | cb4670ea28d3d1f9dc68d7143f6e5c9ef4fd4a60 (patch) | |
tree | 624bb9271e7112c0f20a2d708a82f480df3a3569 | |
parent | ee2a59a20ac4497241a971a17799f65dcca3424a (diff) | |
download | bionic-cb4670ea28d3d1f9dc68d7143f6e5c9ef4fd4a60.tar.gz |
Drop thread list lock before abort.
Bug: 65656273
Test: Ran the app and verified it crashes instead of deadlocks.
Change-Id: I7dbe653d50a635a23993c99c5f73ca094ee80b28
(cherry picked from commit 7982914faefdcc6b0fbb98d63bb9fde48d4efd18)
-rw-r--r-- | libc/bionic/pthread_internal.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libc/bionic/pthread_internal.cpp b/libc/bionic/pthread_internal.cpp index abd403bd4..829194cc7 100644 --- a/libc/bionic/pthread_internal.cpp +++ b/libc/bionic/pthread_internal.cpp @@ -104,9 +104,13 @@ pthread_internal_t* __pthread_internal_find(pthread_t thread_id) { // Check if we're looking for ourselves before acquiring the lock. if (thread == __get_thread()) return thread; - ScopedReadLock locker(&g_thread_list_lock); - for (pthread_internal_t* t = g_thread_list; t != nullptr; t = t->next) { - if (t == thread) return thread; + { + // Make sure to release the lock before the abort below. Otherwise, + // some apps might deadlock in their own crash handlers (see b/6565627). + ScopedReadLock locker(&g_thread_list_lock); + for (pthread_internal_t* t = g_thread_list; t != nullptr; t = t->next) { + if (t == thread) return thread; + } } // Historically we'd return null, but |