src: forbid reset_handler for SIGSEGV handling
This is not easily implementable, and should be explicitly disallowed. 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>
This commit is contained in:
parent
e256204776
commit
89b32378c8
14
src/node.cc
14
src/node.cc
@ -477,13 +477,15 @@ void LoadEnvironment(Environment* env) {
|
|||||||
USE(StartMainThreadExecution(env));
|
USE(StartMainThreadExecution(env));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __POSIX__
|
||||||
|
typedef void (*sigaction_cb)(int signo, siginfo_t* info, void* ucontext);
|
||||||
|
#endif
|
||||||
#if NODE_USE_V8_WASM_TRAP_HANDLER
|
#if NODE_USE_V8_WASM_TRAP_HANDLER
|
||||||
static std::atomic<void (*)(int signo, siginfo_t* info, void* ucontext)>
|
static std::atomic<sigaction_cb> previous_sigsegv_action;
|
||||||
previous_sigsegv_action;
|
|
||||||
|
|
||||||
void TrapWebAssemblyOrContinue(int signo, siginfo_t* info, void* ucontext) {
|
void TrapWebAssemblyOrContinue(int signo, siginfo_t* info, void* ucontext) {
|
||||||
if (!v8::TryHandleWebAssemblyTrapPosix(signo, info, ucontext)) {
|
if (!v8::TryHandleWebAssemblyTrapPosix(signo, info, ucontext)) {
|
||||||
auto prev = previous_sigsegv_action.load();
|
sigaction_cb prev = previous_sigsegv_action.load();
|
||||||
if (prev != nullptr) {
|
if (prev != nullptr) {
|
||||||
prev(signo, info, ucontext);
|
prev(signo, info, ucontext);
|
||||||
} else {
|
} else {
|
||||||
@ -502,13 +504,13 @@ void TrapWebAssemblyOrContinue(int signo, siginfo_t* info, void* ucontext) {
|
|||||||
|
|
||||||
#ifdef __POSIX__
|
#ifdef __POSIX__
|
||||||
void RegisterSignalHandler(int signal,
|
void RegisterSignalHandler(int signal,
|
||||||
void (*handler)(int signal,
|
sigaction_cb handler,
|
||||||
siginfo_t* info,
|
|
||||||
void* ucontext),
|
|
||||||
bool reset_handler) {
|
bool reset_handler) {
|
||||||
|
CHECK_NOT_NULL(handler);
|
||||||
#if NODE_USE_V8_WASM_TRAP_HANDLER
|
#if NODE_USE_V8_WASM_TRAP_HANDLER
|
||||||
if (signal == SIGSEGV) {
|
if (signal == SIGSEGV) {
|
||||||
CHECK(previous_sigsegv_action.is_lock_free());
|
CHECK(previous_sigsegv_action.is_lock_free());
|
||||||
|
CHECK(!reset_handler);
|
||||||
previous_sigsegv_action.store(handler);
|
previous_sigsegv_action.store(handler);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -815,8 +815,12 @@ class NODE_EXTERN AsyncResource {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
// Register a signal handler without interrupting
|
// Register a signal handler without interrupting any handlers that node
|
||||||
// any handlers that node itself needs.
|
// itself needs. This does override handlers registered through
|
||||||
|
// process.on('SIG...', function() { ... }). The `reset_handler` flag indicates
|
||||||
|
// whether the signal handler for the given signal should be reset to its
|
||||||
|
// default value before executing the handler (i.e. it works like SA_RESETHAND).
|
||||||
|
// The `reset_handler` flag is invalid when `signal` is SIGSEGV.
|
||||||
NODE_EXTERN
|
NODE_EXTERN
|
||||||
void RegisterSignalHandler(int signal,
|
void RegisterSignalHandler(int signal,
|
||||||
void (*handler)(int signal,
|
void (*handler)(int signal,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user