Skip to content

Commit 83a1b8b

Browse files
committed
src: remove misplaced windows code under posix guard in node.cc
The V8 WebAssembly trap handler setup for Windows was incorrectly nested within a POSIX conditional compilation block in src/node.cc. This caused the related functions to be effectively non-operational on Windows. The changes involve removing the Windows-specific code from the POSIX section and correctly placing it under the WIN32 checks. This fix will ensure that the intended exception handling is active on Windows builds, potentially improving WebAssembly performance. Fixes: nodejs#52404 Refs: nodejs#35033
1 parent 68f9e1f commit 83a1b8b

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/node.cc

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,11 @@ static LONG TrapWebAssemblyOrContinue(EXCEPTION_POINTERS* exception) {
435435
}
436436
return EXCEPTION_CONTINUE_SEARCH;
437437
}
438+
{
439+
constexpr ULONG first = TRUE;
440+
per_process::old_vectored_exception_handler =
441+
AddVectoredExceptionHandler(first, TrapWebAssemblyOrContinue);
442+
}
438443
#else
439444
static std::atomic<sigaction_cb> previous_sigsegv_action;
440445
// TODO(align behavior between macos and other in next major version)
@@ -635,17 +640,6 @@ static void PlatformInit(ProcessInitializationFlags::Flags flags) {
635640
RegisterSignalHandler(SIGTERM, SignalExit, true);
636641

637642
#if NODE_USE_V8_WASM_TRAP_HANDLER
638-
#if defined(_WIN32)
639-
{
640-
constexpr ULONG first = TRUE;
641-
per_process::old_vectored_exception_handler =
642-
AddVectoredExceptionHandler(first, TrapWebAssemblyOrContinue);
643-
}
644-
#else
645-
// Tell V8 to disable emitting WebAssembly
646-
// memory bounds checks. This means that we have
647-
// to catch the SIGSEGV/SIGBUS in TrapWebAssemblyOrContinue
648-
// and pass the signal context to V8.
649643
{
650644
struct sigaction sa;
651645
memset(&sa, 0, sizeof(sa));
@@ -657,7 +651,6 @@ static void PlatformInit(ProcessInitializationFlags::Flags flags) {
657651
CHECK_EQ(sigaction(SIGBUS, &sa, nullptr), 0);
658652
#endif
659653
}
660-
#endif // defined(_WIN32)
661654
V8::EnableWebAssemblyTrapHandler(false);
662655
#endif // NODE_USE_V8_WASM_TRAP_HANDLER
663656
}

0 commit comments

Comments
 (0)