Drop thread list lock before abort.
Bug: 65656273
Test: Ran the app and verified it crashes instead of deadlocks.
Change-Id: I7dbe653d50a635a23993c99c5f73ca094ee80b28
diff --git a/libc/bionic/pthread_internal.cpp b/libc/bionic/pthread_internal.cpp
index abd403b..829194c 100644
--- a/libc/bionic/pthread_internal.cpp
+++ b/libc/bionic/pthread_internal.cpp
@@ -104,9 +104,13 @@
// 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