summaryrefslogtreecommitdiff
path: root/src/node.cc
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-05-20 01:57:17 +0200
committerAnna Henningsen <anna@addaleax.net>2019-06-14 19:11:40 +0200
commite2562047763a666599b64d016cdbf399dab855d8 (patch)
tree26f7d5f61795169924066892acfba709c3f04ae8 /src/node.cc
parente6b3ec3d3c553200fa98ed47dff12d58ebedf8a2 (diff)
downloadandroid-node-v8-e2562047763a666599b64d016cdbf399dab855d8.tar.gz
android-node-v8-e2562047763a666599b64d016cdbf399dab855d8.tar.bz2
android-node-v8-e2562047763a666599b64d016cdbf399dab855d8.zip
src: reset SIGSEGV handler before crashing
Without this, we would re-enter the signal handler immediately after re-raising the signal, leading to an infinite loop. PR-URL: https://github.com/nodejs/node/pull/27775 Refs: https://github.com/nodejs/node/pull/27246 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src/node.cc')
-rw-r--r--src/node.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/node.cc b/src/node.cc
index 388a9ea448..f4a953a7c3 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -487,6 +487,12 @@ void TrapWebAssemblyOrContinue(int signo, siginfo_t* info, void* ucontext) {
if (prev != nullptr) {
prev(signo, info, ucontext);
} else {
+ // Reset to the default signal handler, i.e. cause a hard crash.
+ struct sigaction sa;
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_handler = SIG_DFL;
+ CHECK_EQ(sigaction(signo, &sa, nullptr), 0);
+
ResetStdio();
raise(signo);
}