Commit 5ac88bfc authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

Revert "Remove trap handler fallback for sanitizers"

This reverts commit 26a78061.

Reason for revert: Not all fuzzers support custom segfault handlers yet, see https://crbug.com/918949

Original change's description:
> Remove trap handler fallback for sanitizers
> 
> Since https://crrev.com/c/1335572, our sanitizers allow to set custom
> segfault handlers. Thus remove special code that was added to handle
> sanitizers that prevent installation of segfault handlers. Instead,
> CHECK that the signal handler was installed correctly.
> 
> R=​ahaas@chromium.org, mseaborn@chromium.org, mark@chromium.org
> 
> Bug: chromium:830894
> Change-Id: I3bd66e33efdceb3e8469f3f4a09fbde90cb3d7ec
> Reviewed-on: https://chromium-review.googlesource.com/c/1392199
> Reviewed-by: Andreas Haas <ahaas@chromium.org>
> Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#58513}

TBR=mseaborn@chromium.org,ahaas@chromium.org,mark@chromium.org,clemensh@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: chromium:830894, chromium:918949
Change-Id: Ide545860cf7729139ac50c0dd2e85facca49b0b1
Reviewed-on: https://chromium-review.googlesource.com/c/1396277Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58556}
parent 8a632f5c
......@@ -13,7 +13,7 @@
// should be as self-contained as possible to make it easy to audit the code.
//
// 2. Any changes must be reviewed by someone from the crash reporting
// or security team. See OWNERS for suggested reviewers.
// or security team. Se OWNERS for suggested reviewers.
//
// For more information, see https://goo.gl/yMeyUY.
//
......@@ -52,21 +52,36 @@ bool RegisterDefaultTrapHandler() {
return false;
}
// Check that the signal handler is indeed registered. Sanitizers for example
// might prevent this, and then report crashes later because signals are not
// being caught correctly.
// Sanitizers often prevent us from installing our own signal handler. Attempt
// to detect this and if so, refuse to enable trap handling.
//
// TODO(chromium:830894): Remove this once all bots support custom signal
// handlers.
#if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \
defined(THREAD_SANITIZER) || defined(LEAK_SANITIZER) || \
defined(UNDEFINED_SANITIZER)
struct sigaction installed_handler;
CHECK_EQ(sigaction(kOobSignal, NULL, &installed_handler), 0);
CHECK_EQ(HandleSignal, installed_handler.sa_sigaction);
// If the installed handler does not point to HandleSignal, then
// allow_user_segv_handler is 0.
if (installed_handler.sa_sigaction != HandleSignal) {
printf(
"WARNING: sanitizers are preventing signal handler installation. "
"Trap handlers are disabled.\n");
return false;
}
#endif
g_is_default_signal_handler_registered = true;
return true;
}
void RemoveTrapHandler() {
if (!g_is_default_signal_handler_registered) return;
if (sigaction(kOobSignal, &g_old_handler, nullptr) != 0) return;
g_is_default_signal_handler_registered = false;
if (g_is_default_signal_handler_registered) {
if (sigaction(kOobSignal, &g_old_handler, nullptr) == 0) {
g_is_default_signal_handler_registered = false;
}
}
}
#endif // V8_TRAP_HANDLER_SUPPORTED
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment