1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

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>
This commit is contained in:
Luca Casonato 2023-09-15 00:17:01 +02:00 committed by GitHub
parent 5e7435fb80
commit 06ece5645c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);