Disable malloc debug intercepts when exiting.
There is a hang when enabling leak_track since the dumping of the
leak data can wind up doing an allocation.
Add new system unit test to make sure this doesn't happen again.
Bug: 111146059
Test: Test program that leaks does not hang forever.
Test: Unit tests pass.
Change-Id: Icf99be58ba5db98ee124a471b957a086045f5870
diff --git a/libc/malloc_debug/malloc_debug.cpp b/libc/malloc_debug/malloc_debug.cpp
index 1e7086c..2e3a0a3 100644
--- a/libc/malloc_debug/malloc_debug.cpp
+++ b/libc/malloc_debug/malloc_debug.cpp
@@ -254,6 +254,9 @@
return;
}
+ // Turn off capturing allocations calls.
+ DebugDisableSet(true);
+
if (g_debug->config().options() & FREE_TRACK) {
PointerData::VerifyAllFreed();
}
@@ -263,15 +266,11 @@
}
if ((g_debug->config().options() & BACKTRACE) && g_debug->config().backtrace_dump_on_exit()) {
- ScopedDisableDebugCalls disable;
debug_dump_heap(android::base::StringPrintf("%s.%d.exit.txt",
g_debug->config().backtrace_dump_prefix().c_str(),
- getpid())
- .c_str());
+ getpid()).c_str());
}
- DebugDisableSet(true);
-
backtrace_shutdown();
delete g_debug;