diff options
author | Josh Gao <jmgao@google.com> | 2017-03-06 17:46:47 -0800 |
---|---|---|
committer | Josh Gao <jmgao@google.com> | 2017-03-08 16:43:59 -0800 |
commit | 222272ece93d35dbb4eb76076f29bbe719bf5c93 (patch) | |
tree | 86afe768d56e72bf0f7b7cd2c6700e8e5221082c /linker/linker_memory.cpp | |
parent | 415daa8cca875d348c003a95cf7c44c9231eae75 (diff) |
linker_memory: allow fallback allocator to be turned on and off.
Let the fallback allocator be used on multiple threads (as long as only
one thread is using it at once).
Bug: http://b/35858739
Change-Id: Id3e2fc6b7c093c6e56870524ffda28946de09e29
Diffstat (limited to 'linker/linker_memory.cpp')
-rw-r--r-- | linker/linker_memory.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/linker/linker_memory.cpp b/linker/linker_memory.cpp index 18ef93e9d..f8852e122 100644 --- a/linker/linker_memory.cpp +++ b/linker/linker_memory.cpp @@ -39,16 +39,22 @@ static pid_t fallback_tid = 0; // Used by libdebuggerd_handler to switch allocators during a crash dump, in // case the linker heap is corrupted. Do not use this function. -extern "C" void __linker_use_fallback_allocator() { +extern "C" void __linker_enable_fallback_allocator() { if (fallback_tid != 0) { - __libc_format_log(ANDROID_LOG_ERROR, "libc", - "attempted to set fallback allocator multiple times"); - return; + __libc_fatal("attempted to use currently-in-use fallback allocator"); } fallback_tid = gettid(); } +extern "C" void __linker_disable_fallback_allocator() { + if (fallback_tid == 0) { + __libc_fatal("attempted to disable unused fallback allocator"); + } + + fallback_tid = 0; +} + static LinkerMemoryAllocator& get_fallback_allocator() { static LinkerMemoryAllocator fallback_allocator; return fallback_allocator; |