diff options
author | Ricardo Cerqueira <ricardo@cyngn.com> | 2015-11-05 01:04:40 +0000 |
---|---|---|
committer | Ricardo Cerqueira <ricardo@cyngn.com> | 2015-11-05 18:26:36 +0000 |
commit | 31756a19f79d62b71fa87c4e656e00bfbb9a5385 (patch) | |
tree | d459d9f2147f52cc1a55d586686cea8603763e3e /libbacktrace/BacktraceCurrent.cpp | |
parent | 22fffcc3d469176f9a7d52d7c6fe68186e9592ab (diff) | |
parent | f7f765fd62bf5db1271e0c0f51e9fb4df609dc6a (diff) | |
download | system_core-31756a19f79d62b71fa87c4e656e00bfbb9a5385.zip system_core-31756a19f79d62b71fa87c4e656e00bfbb9a5385.tar.gz system_core-31756a19f79d62b71fa87c4e656e00bfbb9a5385.tar.bz2 |
Merge tag 'android-6.0.0_r26' into cm-13.0
Android 6.0.0 release 26
Change-Id: I93d1e3767cbacab2b18cff360065c91b9eaf1d96
Diffstat (limited to 'libbacktrace/BacktraceCurrent.cpp')
-rw-r--r-- | libbacktrace/BacktraceCurrent.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/libbacktrace/BacktraceCurrent.cpp b/libbacktrace/BacktraceCurrent.cpp index 2714d93..d339550 100644 --- a/libbacktrace/BacktraceCurrent.cpp +++ b/libbacktrace/BacktraceCurrent.cpp @@ -93,6 +93,10 @@ bool BacktraceCurrent::DiscardFrame(const backtrace_frame_data_t& frame) { static pthread_mutex_t g_sigaction_mutex = PTHREAD_MUTEX_INITIALIZER; +static void SignalLogOnly(int, siginfo_t*, void*) { + BACK_LOGE("pid %d, tid %d: Received a spurious signal %d\n", getpid(), gettid(), THREAD_SIGNAL); +} + static void SignalHandler(int, siginfo_t*, void* sigcontext) { ThreadEntry* entry = ThreadEntry::Get(getpid(), gettid(), false); if (!entry) { @@ -151,9 +155,21 @@ bool BacktraceCurrent::UnwindThread(size_t num_ignore_frames) { // that we are waiting for the first Wake() call made by the thread. bool wait_completed = entry->Wait(1); + if (!wait_completed && oldact.sa_sigaction == nullptr) { + // If the wait failed, it could be that the signal could not be delivered + // within the timeout. Add a signal handler that's simply going to log + // something so that we don't crash if the signal eventually gets + // delivered. Only do this if there isn't already an action set up. + memset(&act, 0, sizeof(act)); + act.sa_sigaction = SignalLogOnly; + act.sa_flags = SA_RESTART | SA_SIGINFO | SA_ONSTACK; + sigemptyset(&act.sa_mask); + sigaction(THREAD_SIGNAL, &act, nullptr); + } else { + sigaction(THREAD_SIGNAL, &oldact, nullptr); + } // After the thread has received the signal, allow other unwinders to // continue. - sigaction(THREAD_SIGNAL, &oldact, nullptr); pthread_mutex_unlock(&g_sigaction_mutex); bool unwind_done = false; |