[msan] Fix signal chaining

Return internally stored handlers only if handlers is set to wrapper

llvm-svn: 317970
This commit is contained in:
Vitaly Buka 2017-11-11 03:03:34 +00:00
parent 24bc8d5905
commit 5f767113c5
2 changed files with 4 additions and 4 deletions

View File

@ -1301,7 +1301,7 @@ static int sigaction_impl(int signo, const __sanitizer_sigaction *act,
res = REAL(sigaction)(signo, pnew_act, oldact);
if (res == 0 && oldact) {
uptr cb = (uptr)oldact->sigaction;
if (cb != __sanitizer::sig_ign && cb != __sanitizer::sig_dfl) {
if (cb == (uptr)SignalAction || cb == (uptr)SignalHandler) {
oldact->sigaction = (decltype(oldact->sigaction))old_cb;
}
}

View File

@ -18,7 +18,7 @@
// clang-format on
// Remove when fixed: https://github.com/google/sanitizers/issues/637
// XFAIL: msan
// XFAIL: tsan
// Flaky errors in debuggerd with "waitpid returned unexpected pid (0)" in logcat.
@ -33,7 +33,7 @@ struct sigaction original_sigaction_sigsegv;
void User_OnSIGSEGV(int signum, siginfo_t *siginfo, void *context) {
fprintf(stderr, "User sigaction called\n");
struct sigaction original_sigaction;
struct sigaction original_sigaction = {};
if (signum == SIGBUS)
original_sigaction = original_sigaction_sigbus;
else if (signum == SIGSEGV)
@ -58,7 +58,7 @@ int DoSEGV() {
}
bool InstallHandler(int signum, struct sigaction *original_sigaction) {
struct sigaction user_sigaction;
struct sigaction user_sigaction = {};
user_sigaction.sa_sigaction = User_OnSIGSEGV;
user_sigaction.sa_flags = SA_SIGINFO;
if (sigaction(signum, &user_sigaction, original_sigaction)) {