[wasm] Make --wasm-trap-handler a d8-only flag

This flag only controls whether d8 installs the signal handler for wasm
traps. Hence it should be a d8-only flag, to avoid confusion if used in
other embeddings.
We just introduced --wasm-enforce-bounds-checks to do what you might
think --no-wasm-trap-handler would do.

R=ahaas@chromium.org

Bug: v8:11926
Change-Id: Ic1f33af36236a2981cf060f450bbfd02e51d9793
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2989130
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75459}
This commit is contained in:
Clemens Backes 2021-06-25 19:33:56 +02:00 committed by V8 LUCI CQ
parent 51dd4ac133
commit 9ca10d840c
7 changed files with 22 additions and 15 deletions

View File

@ -4369,6 +4369,14 @@ bool Shell::SetOptions(int argc, char* argv[]) {
#endif
argv[i] = nullptr;
#endif
#if V8_ENABLE_WEBASSEMBLY
} else if (strcmp(argv[i], "--wasm-trap-handler") == 0) {
options.wasm_trap_handler = true;
argv[i] = nullptr;
} else if (strcmp(argv[i], "--no-wasm-trap-handler") == 0) {
options.wasm_trap_handler = false;
argv[i] = nullptr;
#endif // V8_ENABLE_WEBASSEMBLY
}
}
@ -5074,9 +5082,9 @@ int Shell::Main(int argc, char* argv[]) {
}
#if V8_ENABLE_WEBASSEMBLY
if (V8_TRAP_HANDLER_SUPPORTED && i::FLAG_wasm_trap_handler) {
constexpr bool use_default_trap_handler = true;
if (!v8::V8::EnableWebAssemblyTrapHandler(use_default_trap_handler)) {
if (V8_TRAP_HANDLER_SUPPORTED && options.wasm_trap_handler) {
constexpr bool kUseDefaultTrapHandler = true;
if (!v8::V8::EnableWebAssemblyTrapHandler(kUseDefaultTrapHandler)) {
FATAL("Could not register trap handler");
}
}

View File

@ -430,6 +430,9 @@ class ShellOptions {
"experimental-d8-web-snapshot-api", false};
DisallowReassignment<bool> compile_only = {"compile-only", false};
DisallowReassignment<int> repeat_compile = {"repeat-compile", 1};
#if V8_ENABLE_WEBASSEMBLY
DisallowReassignment<bool> wasm_trap_handler = {"wasm-trap-handler", true};
#endif // V8_ENABLE_WEBASSEMBLY
};
class Shell : public i::AllStatic {

View File

@ -1031,9 +1031,6 @@ DEFINE_BOOL(wasm_math_intrinsics, true,
DEFINE_BOOL(wasm_loop_unrolling, true,
"enable loop unrolling for wasm functions")
DEFINE_BOOL(wasm_trap_handler, true,
"use signal handlers to catch out of bounds memory access in wasm"
" (currently Linux x86_64 only)")
DEFINE_BOOL(wasm_fuzzer_gen_test, false,
"generate a test case when running a wasm fuzzer")
DEFINE_IMPLICATION(wasm_fuzzer_gen_test, single_threaded)

View File

@ -62,7 +62,7 @@ std::unique_ptr<FuzzerSupport> FuzzerSupport::fuzzer_support_;
// static
void FuzzerSupport::InitializeFuzzerSupport(int* argc, char*** argv) {
#if V8_ENABLE_WEBASSEMBLY
if (V8_TRAP_HANDLER_SUPPORTED && i::FLAG_wasm_trap_handler) {
if (V8_TRAP_HANDLER_SUPPORTED) {
constexpr bool kUseDefaultTrapHandler = true;
if (!v8::V8::EnableWebAssemblyTrapHandler(kUseDefaultTrapHandler)) {
FATAL("Could not register trap handler");

View File

@ -52,9 +52,8 @@ sigjmp_buf SignalHandlerFallbackTest::continuation_;
TEST_F(SignalHandlerFallbackTest, DoTest) {
const int save_sigs = 1;
if (!sigsetjmp(continuation_, save_sigs)) {
constexpr bool use_default_signal_handler = true;
EXPECT_TRUE(
v8::V8::EnableWebAssemblyTrapHandler(use_default_signal_handler));
constexpr bool kUseDefaultTrapHandler = true;
EXPECT_TRUE(v8::V8::EnableWebAssemblyTrapHandler(kUseDefaultTrapHandler));
CrashOnPurpose();
FAIL();
} else {

View File

@ -73,8 +73,8 @@ class ExceptionHandlerFallbackTest : public ::testing::Test {
};
TEST_F(ExceptionHandlerFallbackTest, DoTest) {
constexpr bool use_default_handler = true;
EXPECT_TRUE(v8::V8::EnableWebAssemblyTrapHandler(use_default_handler));
constexpr bool kUseDefaultTrapHandler = true;
EXPECT_TRUE(v8::V8::EnableWebAssemblyTrapHandler(kUseDefaultTrapHandler));
// In the original test setup the test memory is protected against any kind of
// access. Therefore the access here causes an access violation exception,
// which should be caught by the exception handler we install above. In the

View File

@ -15,9 +15,9 @@ int main(int argc, char** argv) {
testing::InitGoogleMock(&argc, argv);
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
v8::V8::InitializeExternalStartupData(argv[0]);
if (V8_TRAP_HANDLER_SUPPORTED && i::FLAG_wasm_trap_handler) {
constexpr bool use_default_trap_handler = true;
if (!v8::V8::EnableWebAssemblyTrapHandler(use_default_trap_handler)) {
if (V8_TRAP_HANDLER_SUPPORTED) {
constexpr bool kUseDefaultTrapHandler = true;
if (!v8::V8::EnableWebAssemblyTrapHandler(kUseDefaultTrapHandler)) {
FATAL("Could not register trap handler");
}
}