summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Gao2018-04-27 15:31:47 -0500
committerJosh Gao2018-04-27 15:31:47 -0500
commit38ac45df1738496d5581b89845e48daeab7f0219 (patch)
tree3d17bc16c9be7e9856e9dc7d139bfd23db6e7312 /debuggerd
parenta3721db3338c051c7f31fc6e70ca08c740e28761 (diff)
downloadplatform-system-core-38ac45df1738496d5581b89845e48daeab7f0219.tar.gz
platform-system-core-38ac45df1738496d5581b89845e48daeab7f0219.tar.xz
platform-system-core-38ac45df1738496d5581b89845e48daeab7f0219.zip
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
Diffstat (limited to 'debuggerd')
-rw-r--r--debuggerd/crash_dump.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/debuggerd/crash_dump.cpp b/debuggerd/crash_dump.cpp
index a1f021184..40cf6c340 100644
--- a/debuggerd/crash_dump.cpp
+++ b/debuggerd/crash_dump.cpp
@@ -190,6 +190,19 @@ static bool g_tombstoned_connected = false;
190static unique_fd g_tombstoned_socket; 190static unique_fd g_tombstoned_socket;
191static unique_fd g_output_fd; 191static unique_fd g_output_fd;
192 192
193static void DefuseSignalHandlers() {
194 // Don't try to dump ourselves.
195 struct sigaction action = {};
196 action.sa_handler = SIG_DFL;
197 debuggerd_register_handlers(&action);
198
199 sigset_t mask;
200 sigemptyset(&mask);
201 if (sigprocmask(SIG_SETMASK, &mask, nullptr) != 0) {
202 PLOG(FATAL) << "failed to set signal mask";
203 }
204}
205
193static void Initialize(char** argv) { 206static void Initialize(char** argv) {
194 android::base::InitLogging(argv); 207 android::base::InitLogging(argv);
195 android::base::SetAborter([](const char* abort_msg) { 208 android::base::SetAborter([](const char* abort_msg) {
@@ -213,17 +226,6 @@ static void Initialize(char** argv) {
213 226
214 _exit(1); 227 _exit(1);
215 }); 228 });
216
217 // Don't try to dump ourselves.
218 struct sigaction action = {};
219 action.sa_handler = SIG_DFL;
220 debuggerd_register_handlers(&action);
221
222 sigset_t mask;
223 sigemptyset(&mask);
224 if (sigprocmask(SIG_SETMASK, &mask, nullptr) != 0) {
225 PLOG(FATAL) << "failed to set signal mask";
226 }
227} 229}
228 230
229static void ParseArgs(int argc, char** argv, pid_t* pseudothread_tid, DebuggerdDumpType* dump_type) { 231static 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) {
321} 323}
322 324
323int main(int argc, char** argv) { 325int main(int argc, char** argv) {
326 DefuseSignalHandlers();
327
324 atrace_begin(ATRACE_TAG, "before reparent"); 328 atrace_begin(ATRACE_TAG, "before reparent");
325 pid_t target_process = getppid(); 329 pid_t target_process = getppid();
326 330