summaryrefslogtreecommitdiff
path: root/libc/malloc_debug/malloc_debug.cpp
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2021-07-15 19:58:24 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-07-15 19:58:24 +0000
commitbde9d6ba82b8c8b8cbdf116d0ad615ccd2592e98 (patch)
treea1a5bfa23949cf21e41ae2acc9b7ef75c1c01fd6 /libc/malloc_debug/malloc_debug.cpp
parentb9f5f5c1de90d187f601825bbd8dac372bd2e8bf (diff)
parente9b672b3e0f94f020689eb9df1195ef410c9c1f4 (diff)
Fix race when frees after main thread finishes. am: e9b672b3e0
Original change: https://googleplex-android-review.googlesource.com/c/platform/bionic/+/15291503 Change-Id: I9f69a89b94f0b43ca034cea2ea3491980d486ce9
Diffstat (limited to 'libc/malloc_debug/malloc_debug.cpp')
-rw-r--r--libc/malloc_debug/malloc_debug.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/libc/malloc_debug/malloc_debug.cpp b/libc/malloc_debug/malloc_debug.cpp
index 609f030bf..d23ab15c3 100644
--- a/libc/malloc_debug/malloc_debug.cpp
+++ b/libc/malloc_debug/malloc_debug.cpp
@@ -362,10 +362,9 @@ void debug_finalize() {
backtrace_shutdown();
- delete g_debug;
- g_debug = nullptr;
-
- DebugDisableFinalize();
+ // In order to prevent any issues of threads freeing previous pointers
+ // after the main thread calls this code, simply leak the g_debug pointer
+ // and do not destroy the debug disable pthread key.
}
void debug_get_malloc_leak_info(uint8_t** info, size_t* overall_size, size_t* info_size,