summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2023-09-15 00:17:01 +0200
committerGitHub <noreply@github.com>2023-09-15 00:17:01 +0200
commit06ece5645c07471a740af8ee622da970845daae7 (patch)
treeba5dd53a04fac72f21159016b87c76ca1b843a1b
parent5e7435fb8010a6d90f1b88d68ee8c431abf846e1 (diff)
fix: init v8 platform once on main thread (#20495)
This is a mitigation for segfaults happening in V8 on CPU with MPK (memory protected keys). After much trail and error we found that unless V8 platform is initialized on main thread the segfaults start appears once JIT kicks in. "deno test" and "deno bench" were affected by this problem. Fixes https://github.com/denoland/deno/issues/19926 Fixes https://github.com/denoland/deno/issues/20243 Fixes https://github.com/denoland/deno/issues/20450 --------- Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com>
-rw-r--r--cli/main.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/cli/main.rs b/cli/main.rs
index 9044a14da..df5dd0b26 100644
--- a/cli/main.rs
+++ b/cli/main.rs
@@ -264,6 +264,10 @@ pub fn main() {
let args: Vec<String> = env::args().collect();
+ // NOTE(lucacasonato): due to new PKU feature introduced in V8 11.6 we need to
+ // initalize the V8 platform on a parent thread of all threads that will spawn
+ // V8 isolates.
+
let future = async move {
let current_exe_path = current_exe()?;
let standalone_res =
@@ -296,6 +300,7 @@ pub fn main() {
_ => vec![],
};
init_v8_flags(&default_v8_flags, &flags.v8_flags, get_v8_flags_from_env());
+ deno_core::JsRuntime::init_platform(None);
util::logger::init(flags.log_level);