diff options
author | Michaƫl Zasso <targos@protonmail.com> | 2018-01-24 20:16:06 +0100 |
---|---|---|
committer | Myles Borins <mylesborins@google.com> | 2018-01-24 15:02:20 -0800 |
commit | 4c4af643e5042d615a60c6bbc05aee9d81b903e5 (patch) | |
tree | 3fb0a97988fe4439ae3ae06f26915d1dcf8cab92 /deps/v8/src/trap-handler | |
parent | fa9f31a4fda5a3782c652e56e394465805ebb50f (diff) | |
download | android-node-v8-4c4af643e5042d615a60c6bbc05aee9d81b903e5.tar.gz android-node-v8-4c4af643e5042d615a60c6bbc05aee9d81b903e5.tar.bz2 android-node-v8-4c4af643e5042d615a60c6bbc05aee9d81b903e5.zip |
deps: update V8 to 6.4.388.40
PR-URL: https://github.com/nodejs/node/pull/17489
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Diffstat (limited to 'deps/v8/src/trap-handler')
-rw-r--r-- | deps/v8/src/trap-handler/handler-inside.cc | 14 | ||||
-rw-r--r-- | deps/v8/src/trap-handler/handler-outside.cc | 13 | ||||
-rw-r--r-- | deps/v8/src/trap-handler/handler-shared.cc | 17 | ||||
-rw-r--r-- | deps/v8/src/trap-handler/trap-handler-internal.h | 7 | ||||
-rw-r--r-- | deps/v8/src/trap-handler/trap-handler.h | 5 |
5 files changed, 41 insertions, 15 deletions
diff --git a/deps/v8/src/trap-handler/handler-inside.cc b/deps/v8/src/trap-handler/handler-inside.cc index 9336636b21..d3c543f4f4 100644 --- a/deps/v8/src/trap-handler/handler-inside.cc +++ b/deps/v8/src/trap-handler/handler-inside.cc @@ -102,13 +102,15 @@ bool TryHandleSignal(int signum, siginfo_t* info, ucontext_t* context) { if (TryFindLandingPad(fault_addr, &landing_pad)) { // Tell the caller to return to the landing pad. context->uc_mcontext.gregs[REG_RIP] = landing_pad; + // We will return to wasm code, so restore the g_thread_in_wasm_code flag. + g_thread_in_wasm_code = true; return true; } } // end signal mask scope // If we get here, it's not a recoverable wasm fault, so we go to the next - // handler. - g_thread_in_wasm_code = true; + // handler. Leave the g_thread_in_wasm_code flag unset since we do not return + // to wasm code. return false; } @@ -160,18 +162,14 @@ void HandleSignal(int signum, siginfo_t* info, void* context) { if (!TryHandleSignal(signum, info, uc)) { // Since V8 didn't handle this signal, we want to re-raise the same signal. - // For kernel-generated SEGV signals, we do this by restoring the default + // For kernel-generated SEGV signals, we do this by restoring the original // SEGV handler and then returning. The fault will happen again and the // usual SEGV handling will happen. // // We handle user-generated signals by calling raise() instead. This is for // completeness. We should never actually see one of these, but just in // case, we do the right thing. - struct sigaction action; - action.sa_handler = SIG_DFL; - sigemptyset(&action.sa_mask); - action.sa_flags = 0; - sigaction(signum, &action, nullptr); + RestoreOriginalSignalHandler(); if (!IsKernelGeneratedSignal(info)) { raise(signum); } diff --git a/deps/v8/src/trap-handler/handler-outside.cc b/deps/v8/src/trap-handler/handler-outside.cc index 5cb9661e7b..2c9225d485 100644 --- a/deps/v8/src/trap-handler/handler-outside.cc +++ b/deps/v8/src/trap-handler/handler-outside.cc @@ -115,7 +115,7 @@ void ValidateCodeObjects() { CodeProtectionInfo* CreateHandlerData( void* base, size_t size, size_t num_protected_instructions, - ProtectedInstructionData* protected_instructions) { + const ProtectedInstructionData* protected_instructions) { const size_t alloc_size = HandlerDataSize(num_protected_instructions); CodeProtectionInfo* data = reinterpret_cast<CodeProtectionInfo*>(malloc(alloc_size)); @@ -143,9 +143,9 @@ void UpdateHandlerDataCodePointer(int index, void* base) { data->base = base; } -int RegisterHandlerData(void* base, size_t size, - size_t num_protected_instructions, - ProtectedInstructionData* protected_instructions) { +int RegisterHandlerData( + void* base, size_t size, size_t num_protected_instructions, + const ProtectedInstructionData* protected_instructions) { // TODO(eholk): in debug builds, make sure this data isn't already registered. CodeProtectionInfo* data = CreateHandlerData( @@ -248,6 +248,8 @@ void ReleaseHandlerData(int index) { bool RegisterDefaultSignalHandler() { #if V8_TRAP_HANDLER_SUPPORTED + CHECK(!g_is_default_signal_handler_registered); + struct sigaction action; action.sa_sigaction = HandleSignal; action.sa_flags = SA_SIGINFO; @@ -255,10 +257,11 @@ bool RegisterDefaultSignalHandler() { // {sigaction} installs a new custom segfault handler. On success, it returns // 0. If we get a nonzero value, we report an error to the caller by returning // false. - if (sigaction(SIGSEGV, &action, nullptr) != 0) { + if (sigaction(SIGSEGV, &action, &g_old_handler) != 0) { return false; } + g_is_default_signal_handler_registered = true; return true; #else return false; diff --git a/deps/v8/src/trap-handler/handler-shared.cc b/deps/v8/src/trap-handler/handler-shared.cc index 19f8b5bf68..d07f7ae131 100644 --- a/deps/v8/src/trap-handler/handler-shared.cc +++ b/deps/v8/src/trap-handler/handler-shared.cc @@ -26,7 +26,22 @@ namespace trap_handler { // We declare this as int rather than bool as a workaround for a glibc bug, in // which the dynamic loader cannot handle executables whose TLS area is only // 1 byte in size; see https://sourceware.org/bugzilla/show_bug.cgi?id=14898. -THREAD_LOCAL int g_thread_in_wasm_code = false; +THREAD_LOCAL int g_thread_in_wasm_code; + +#if V8_TRAP_HANDLER_SUPPORTED +// When using the default signal handler, we save the old one to restore in case +// V8 chooses not to handle the signal. +struct sigaction g_old_handler; +bool g_is_default_signal_handler_registered; +#endif + +V8_EXPORT_PRIVATE void RestoreOriginalSignalHandler() { +#if V8_TRAP_HANDLER_SUPPORTED + if (sigaction(SIGSEGV, &g_old_handler, nullptr) == 0) { + g_is_default_signal_handler_registered = false; + } +#endif +} static_assert(sizeof(g_thread_in_wasm_code) > 1, "sizeof(thread_local_var) must be > 1, see " diff --git a/deps/v8/src/trap-handler/trap-handler-internal.h b/deps/v8/src/trap-handler/trap-handler-internal.h index 7897bd0ecc..1476eb844b 100644 --- a/deps/v8/src/trap-handler/trap-handler-internal.h +++ b/deps/v8/src/trap-handler/trap-handler-internal.h @@ -68,6 +68,13 @@ extern std::atomic_size_t gRecoveredTrapCount; // unchanged. bool TryFindLandingPad(uintptr_t fault_addr, uintptr_t* landing_pad); +#if V8_TRAP_HANDLER_SUPPORTED +// When using the default signal handler, we save the old one to restore in case +// V8 chooses not to handle the signal. +extern struct sigaction g_old_handler; +extern bool g_is_default_signal_handler_registered; +#endif + } // namespace trap_handler } // namespace internal } // namespace v8 diff --git a/deps/v8/src/trap-handler/trap-handler.h b/deps/v8/src/trap-handler/trap-handler.h index 7189c27e29..612cf51b45 100644 --- a/deps/v8/src/trap-handler/trap-handler.h +++ b/deps/v8/src/trap-handler/trap-handler.h @@ -50,9 +50,11 @@ void UpdateHandlerDataCodePointer(int index, void* base); /// UpdateHandlerDataCodePointer and ReleaseHandlerData, or -1 on failure. int RegisterHandlerData(void* base, size_t size, size_t num_protected_instructions, - ProtectedInstructionData* protected_instructions); + const ProtectedInstructionData* protected_instructions); /// Removes the data from the master list and frees any memory, if necessary. +/// TODO(mtrofin): once FLAG_wasm_jit_to_native is not needed, we can switch +/// to using size_t for index and not need kInvalidIndex. void ReleaseHandlerData(int index); #if V8_OS_WIN @@ -87,6 +89,7 @@ inline void ClearThreadInWasm() { } bool RegisterDefaultSignalHandler(); +V8_EXPORT_PRIVATE void RestoreOriginalSignalHandler(); #if V8_OS_LINUX bool TryHandleSignal(int signum, siginfo_t* info, ucontext_t* context); |