crash_dump: defuse our signal handlers earlier.

We have a LOG(FATAL) that can potentially happen before we turn off
SIGABRT. Move the signal handler defusing to the very start of main.

Bug: http://b/77920633
Test: treehugger
Change-Id: I7a2f2a0f2bed16e54467388044eca254102aa6a0
This commit is contained in:
Josh Gao 2018-04-27 13:31:47 -07:00
parent a3721db333
commit 38ac45df17
1 changed files with 15 additions and 11 deletions

View File

@ -190,6 +190,19 @@ static bool g_tombstoned_connected = false;
static unique_fd g_tombstoned_socket;
static unique_fd g_output_fd;
static void DefuseSignalHandlers() {
// Don't try to dump ourselves.
struct sigaction action = {};
action.sa_handler = SIG_DFL;
debuggerd_register_handlers(&action);
sigset_t mask;
sigemptyset(&mask);
if (sigprocmask(SIG_SETMASK, &mask, nullptr) != 0) {
PLOG(FATAL) << "failed to set signal mask";
}
}
static void Initialize(char** argv) {
android::base::InitLogging(argv);
android::base::SetAborter([](const char* abort_msg) {
@ -213,17 +226,6 @@ static void Initialize(char** argv) {
_exit(1);
});
// Don't try to dump ourselves.
struct sigaction action = {};
action.sa_handler = SIG_DFL;
debuggerd_register_handlers(&action);
sigset_t mask;
sigemptyset(&mask);
if (sigprocmask(SIG_SETMASK, &mask, nullptr) != 0) {
PLOG(FATAL) << "failed to set signal mask";
}
}
static void ParseArgs(int argc, char** argv, pid_t* pseudothread_tid, DebuggerdDumpType* dump_type) {
@ -321,6 +323,8 @@ static pid_t wait_for_vm_process(pid_t pseudothread_tid) {
}
int main(int argc, char** argv) {
DefuseSignalHandlers();
atrace_begin(ATRACE_TAG, "before reparent");
pid_t target_process = getppid();