Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix segmentation fault in tests on CPUs with PKU support #471

Merged
merged 4 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ include_icu_data = []
v8_use_custom_libcxx = ["v8/use_custom_libcxx"]
include_js_files_for_snapshotting = []
unsafe_runtime_options = []
testing = []
Digifox03 marked this conversation as resolved.
Show resolved Hide resolved

# Use the old, slower (but better tested) JoinSet driver
op_driver_joinset = []
Expand Down
12 changes: 10 additions & 2 deletions core/runtime/jsruntime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,16 @@ fn v8_init(
};
v8::V8::set_flags_from_string(&flags);

let v8_platform = v8_platform
.unwrap_or_else(|| v8::new_default_platform(0, false).make_shared());
let v8_platform = v8_platform.unwrap_or_else(|| {
if cfg!(any(test, feature = "testing")) {
Digifox03 marked this conversation as resolved.
Show resolved Hide resolved
// We don't want to use the default platform in tests, because it
// uses memory protection keys which break multi-threaded tests.
v8::new_unprotected_default_platform(0, false)
} else {
v8::new_default_platform(0, false)
}
.make_shared()
});
v8::V8::initialize_platform(v8_platform.clone());
v8::V8::initialize();

Expand Down
3 changes: 2 additions & 1 deletion serde_v8/magic/v8slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ where
static V8_ONCE: std::sync::Once = std::sync::Once::new();

V8_ONCE.call_once(|| {
let platform = v8::new_default_platform(0, false).make_shared();
let platform =
Digifox03 marked this conversation as resolved.
Show resolved Hide resolved
v8::new_unprotected_default_platform(0, false).make_shared();
v8::V8::initialize_platform(platform);
v8::V8::initialize();
});
Expand Down
2 changes: 1 addition & 1 deletion serde_v8/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn js_exec<'s>(
}

pub fn v8_init() {
Digifox03 marked this conversation as resolved.
Show resolved Hide resolved
let platform = v8::new_default_platform(0, false).make_shared();
let platform = v8::new_unprotected_default_platform(0, false).make_shared();
v8::V8::initialize_platform(platform);
v8::V8::initialize();
}
Expand Down
1 change: 1 addition & 0 deletions testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ path = "./lib.rs"

[dev-dependencies]
deno_core.workspace = true
deno_core.features = ["testing"]
pretty_assertions.workspace = true
prettyplease.workspace = true
testing_macros.workspace = true
Expand Down