Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7302097e authored by Josh Gao's avatar Josh Gao
Browse files

debuggerd: wait for dump completion on crashes.

When a process crashes, both ActivityManager and init will try to kill
its process group when they notice. The recent change to minimize the
amount of time a process is paused results in crash dumps being killed
before they finish as a result of this. Since anything that needs to be
low-latency is probably not going to be too happy if it crashes, just
wait for completion whenever we're processing a real crash.

Bug: http://b/70343110
Test: debuggerd_test
Change-Id: I894bb06efd264b1ba005df06f7326a72f4b767bb
parent 18f25d39
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -395,9 +395,6 @@ static int debuggerd_dispatch_pseudothread(void* arg) {
  // crash_dump is ptracing us, fork off a copy of our address space for it to use.
  create_vm_process();

  input_read.reset();
  input_write.reset();

  // Don't leave a zombie child.
  int status;
  if (TEMP_FAILURE_RETRY(waitpid(crash_dump_pid, &status, 0)) == -1) {
@@ -406,6 +403,14 @@ static int debuggerd_dispatch_pseudothread(void* arg) {
  } else if (WIFSTOPPED(status) || WIFSIGNALED(status)) {
    async_safe_format_log(ANDROID_LOG_FATAL, "libc", "crash_dump helper crashed or stopped");
  }

  if (thread_info->siginfo->si_signo != DEBUGGER_SIGNAL) {
    // For crashes, we don't need to minimize pause latency.
    // Wait for the dump to complete before having the process exit, to avoid being murdered by
    // ActivityManager or init.
    TEMP_FAILURE_RETRY(read(input_read, &buf, sizeof(buf)));
  }

  return 0;
}