aboutsummaryrefslogtreecommitdiffstats
path: root/libc/bionic/malloc_debug_common.cpp
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2014-07-09 17:16:07 -0700
committerChristopher Ferris <cferris@google.com>2014-07-09 21:27:15 -0700
commitdda1c6c466c4f31de31d76c8be7e46c16b4b4209 (patch)
tree33df23032fdd6451750acc4f87ea0e298d2cee5b /libc/bionic/malloc_debug_common.cpp
parent4c199170a84e725a56b7d40c113c9d76a75d89ab (diff)
downloadandroid_bionic-dda1c6c466c4f31de31d76c8be7e46c16b4b4209.tar.gz
android_bionic-dda1c6c466c4f31de31d76c8be7e46c16b4b4209.tar.bz2
android_bionic-dda1c6c466c4f31de31d76c8be7e46c16b4b4209.zip
Do not include libc_common in malloc debug code.
The inclusion of the static libc_common library in the malloc_debug_XXX.so shared libraries causes constructors to be called twice. This doesn't seem to have caused any issues when setting the libc.debug.malloc property. However, jemalloc crashes because there are two jemalloc implementations, one in the static libc_common library and one in the shared library. Each implementation has created overlapping thread keys that are not the same. The crash comes because one of the jemalloc keys is actually used by the locale setting code. Thus if someone sets the locale, the jemalloc code crashes trying to access the same key. Change-Id: Iaac650a82d69064db148a6333e9403744f68b4a4
Diffstat (limited to 'libc/bionic/malloc_debug_common.cpp')
-rw-r--r--libc/bionic/malloc_debug_common.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/libc/bionic/malloc_debug_common.cpp b/libc/bionic/malloc_debug_common.cpp
index 9399237fb..be16625b8 100644
--- a/libc/bionic/malloc_debug_common.cpp
+++ b/libc/bionic/malloc_debug_common.cpp
@@ -46,6 +46,16 @@
#include "private/ScopedPthreadMutexLocker.h"
+#if defined(USE_JEMALLOC)
+#include "jemalloc.h"
+#define Malloc(function) je_ ## function
+#elif defined(USE_DLMALLOC)
+#include "dlmalloc.h"
+#define Malloc(function) dl ## function
+#else
+#error "Either one of USE_DLMALLOC or USE_JEMALLOC must be defined."
+#endif
+
// In a VM process, this is set to 1 after fork()ing out of zygote.
int gMallocLeakZygoteChild = 0;
@@ -408,7 +418,7 @@ static void malloc_init_impl() {
dlclose(malloc_impl_handle);
return;
}
- if (!malloc_debug_initialize(&g_hash_table)) {
+ if (!malloc_debug_initialize(&g_hash_table, &__libc_malloc_default_dispatch)) {
dlclose(malloc_impl_handle);
return;
}