diff options
author | Christopher Ferris <cferris@google.com> | 2019-04-17 17:30:22 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-04-17 17:30:22 +0000 |
commit | 21f5850627bb9d5485073e6c07ba7b05067f7b16 (patch) | |
tree | 1ce9d5e55072afdb2796b611c311f6091c73db44 /libc/bionic/malloc_common_dynamic.cpp | |
parent | bc3e37ca2357dafaf31680f317f6090611e50313 (diff) | |
parent | ab1c43dd6da311a2df0d5fdf55d3971df64384cb (diff) | |
download | android_bionic-21f5850627bb9d5485073e6c07ba7b05067f7b16.tar.gz android_bionic-21f5850627bb9d5485073e6c07ba7b05067f7b16.tar.bz2 android_bionic-21f5850627bb9d5485073e6c07ba7b05067f7b16.zip |
Merge "Remove gMallocLeakZygoteChild." into qt-dev
Diffstat (limited to 'libc/bionic/malloc_common_dynamic.cpp')
-rw-r--r-- | libc/bionic/malloc_common_dynamic.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/libc/bionic/malloc_common_dynamic.cpp b/libc/bionic/malloc_common_dynamic.cpp index e7147a0e8..64f9f6f7b 100644 --- a/libc/bionic/malloc_common_dynamic.cpp +++ b/libc/bionic/malloc_common_dynamic.cpp @@ -46,6 +46,7 @@ // write_malloc_leak_info: Writes the leak info data to a file. #include <dlfcn.h> +#include <errno.h> #include <fcntl.h> #include <pthread.h> #include <stdatomic.h> @@ -73,6 +74,8 @@ // ============================================================================= pthread_mutex_t gGlobalsMutateLock = PTHREAD_MUTEX_INITIALIZER; +bool gZygoteChild = false; + _Atomic bool gGlobalsMutating = false; // ============================================================================= @@ -112,7 +115,7 @@ static constexpr char kDebugPropertyProgram[] = "libc.debug.malloc.program"; static constexpr char kDebugEnvOptions[] = "LIBC_DEBUG_MALLOC_OPTIONS"; typedef void (*finalize_func_t)(); -typedef bool (*init_func_t)(const MallocDispatch*, int*, const char*); +typedef bool (*init_func_t)(const MallocDispatch*, bool*, const char*); typedef void (*get_malloc_leak_info_func_t)(uint8_t**, size_t*, size_t*, size_t*, size_t*); typedef void (*free_malloc_leak_info_func_t)(uint8_t*); typedef bool (*write_malloc_leak_info_func_t)(FILE*); @@ -329,7 +332,7 @@ void* LoadSharedLibrary(const char* shared_lib, const char* prefix, MallocDispat bool FinishInstallHooks(libc_globals* globals, const char* options, const char* prefix) { init_func_t init_func = reinterpret_cast<init_func_t>(gFunctions[FUNC_INITIALIZE]); - if (!init_func(&__libc_malloc_default_dispatch, &gMallocLeakZygoteChild, options)) { + if (!init_func(&__libc_malloc_default_dispatch, &gZygoteChild, options)) { error_log("%s: failed to enable malloc %s", getprogname(), prefix); ClearGlobalFunctions(); return false; @@ -470,6 +473,14 @@ extern "C" ssize_t malloc_backtrace(void* pointer, uintptr_t* frames, size_t fra // Platform-internal mallopt variant. // ============================================================================= extern "C" bool android_mallopt(int opcode, void* arg, size_t arg_size) { + if (opcode == M_SET_ZYGOTE_CHILD) { + if (arg != nullptr || arg_size != 0) { + errno = EINVAL; + return false; + } + gZygoteChild = true; + return true; + } if (opcode == M_SET_ALLOCATION_LIMIT_BYTES) { return LimitEnable(arg, arg_size); } |