summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2021-06-09 21:15:01 +0000
committerChristopher Ferris <cferris@google.com>2021-06-10 01:24:50 +0000
commit49e5a765440604eac1208c831c1cd8c0f97cb09e (patch)
tree9a782f39f24e1fe4f9f150b240d16e27336a494f
parenta35d50c2349c54e404d0e4fe40dbd7886babf774 (diff)
downloadcore-49e5a765440604eac1208c831c1cd8c0f97cb09e.tar.gz
Avoid thread cache in unwinder.
The code in the fallback path calls pthread_key_create when using the normal thread cache. However, this code is executed out of the linker, which means that the call doesn't see keys created by the libc version of pthread_key_create. As of now, simply avoid using the thread cache to avoid this problem. Bug: 189803009 Test: debuggerd -b on a media process on a 32 bit Android Go device Test: and observe no crash. Test: debuggerd unit tests pass. Change-Id: I9ca1a55e44d3bb69d49450826d7d64d7a64145c3
-rw-r--r--debuggerd/handler/debuggerd_fallback.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/debuggerd/handler/debuggerd_fallback.cpp b/debuggerd/handler/debuggerd_fallback.cpp
index feafa7377..f61578068 100644
--- a/debuggerd/handler/debuggerd_fallback.cpp
+++ b/debuggerd/handler/debuggerd_fallback.cpp
@@ -87,6 +87,12 @@ static void debuggerd_fallback_trace(int output_fd, ucontext_t* ucontext) {
// TODO: Create this once and store it in a global?
unwindstack::UnwinderFromPid unwinder(kMaxFrames, getpid());
+ // Do not use the thread cache here because it will call pthread_key_create
+ // which doesn't work in linker code. See b/189803009.
+ // Use a normal cached object because the process is stopped, and there
+ // is no chance of data changing between reads.
+ auto process_memory = unwindstack::Memory::CreateProcessMemoryCached(getpid());
+ unwinder.SetProcessMemory(process_memory);
dump_backtrace_thread(output_fd, &unwinder, thread);
}
__linker_disable_fallback_allocator();