From 50871b2aa3728c34d5ce45bb8052c7bbdf1d0255 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Mon, 16 Dec 2024 05:51:49 -0800 Subject: [PATCH] fix: FastString v8_string() should error when cannot allocated (#27375) Upgrades deno_core to 0.326.0 --- Cargo.lock | 17 +++++++++-------- Cargo.toml | 2 +- cli/lsp/tsc.rs | 1 + ext/fs/ops.rs | 8 +------- ext/node/ops/v8.rs | 7 ++++++- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 077f1e1e18..b0ea574b2e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1483,9 +1483,9 @@ dependencies = [ [[package]] name = "deno_core" -version = "0.324.0" +version = "0.326.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24503eda646f246aa6eb0f794909f9a857c8f05095fed66f36e0eaef92edce23" +checksum = "ed157162dc5320a2b46ffeeaec24788339df0f2437cfaea78a8d82696715ad7f" dependencies = [ "anyhow", "az", @@ -1493,6 +1493,7 @@ dependencies = [ "bit-set", "bit-vec", "bytes", + "capacity_builder", "cooked-waker", "deno_core_icudata", "deno_ops", @@ -2052,9 +2053,9 @@ dependencies = [ [[package]] name = "deno_ops" -version = "0.200.0" +version = "0.202.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a529a2c488cd3042f12f35666569ebe5b3cf89d2b7d1cafc1a652f6d7bcc8f" +checksum = "4dd8ac1af251e292388e516dd339b9a3b982a6d1e7f8644c08e34671ca39003c" dependencies = [ "proc-macro-rules", "proc-macro2", @@ -6694,9 +6695,9 @@ dependencies = [ [[package]] name = "serde_v8" -version = "0.233.0" +version = "0.235.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307f176b7475480cee690c34c7118f96fe564d1f2a974bf990294b8310ae4983" +checksum = "d07afd8b67b4a442ecc2823038473ac0e9e5682de93c213323b60661afdd7eb4" dependencies = [ "num-bigint", "serde", @@ -8281,9 +8282,9 @@ dependencies = [ [[package]] name = "v8" -version = "130.0.1" +version = "130.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c23b5c2caff00209b03a716609b275acae94b02dd3b63c4648e7232a84a8402f" +checksum = "2ee0be58935708fa4d7efb970c6cf9f2d9511d24ee24246481a65b6ee167348d" dependencies = [ "bindgen", "bitflags 2.6.0", diff --git a/Cargo.toml b/Cargo.toml index 27038110d3..984cb187ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,7 @@ repository = "https://github.com/denoland/deno" [workspace.dependencies] deno_ast = { version = "=0.44.0", features = ["transpiling"] } -deno_core = { version = "0.324.0" } +deno_core = { version = "0.326.0" } deno_bench_util = { version = "0.176.0", path = "./bench_util" } deno_config = { version = "=0.39.3", features = ["workspace", "sync"] } diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index 931e008a72..957c3a6859 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -4496,6 +4496,7 @@ impl<'a> ToV8<'a> for TscRequestArray { let method_name = deno_core::FastString::from_static(method_name) .v8_string(scope) + .unwrap() .into(); let args = args.unwrap_or_else(|| v8::Array::new(scope, 0).into()); let scope_url = serde_v8::to_v8(scope, self.scope) diff --git a/ext/fs/ops.rs b/ext/fs/ops.rs index 5e64585e0c..521ff65471 100644 --- a/ext/fs/ops.rs +++ b/ext/fs/ops.rs @@ -1411,19 +1411,13 @@ impl<'s> ToV8<'s> for V8MaybeStaticStr { self, scope: &mut v8::HandleScope<'s>, ) -> Result, Self::Error> { - // todo(https://github.com/denoland/deno_core/pull/986): remove this check - // when upgrading deno_core - const MAX_V8_STRING_LENGTH: usize = 536870888; - if self.0.len() > MAX_V8_STRING_LENGTH { - return Err(FastStringV8AllocationError); - } - Ok( match self.0 { Cow::Borrowed(text) => FastString::from_static(text), Cow::Owned(value) => value.into(), } .v8_string(scope) + .map_err(|_| FastStringV8AllocationError)? .into(), ) } diff --git a/ext/node/ops/v8.rs b/ext/node/ops/v8.rs index 61f67f11f7..8f09314d1d 100644 --- a/ext/node/ops/v8.rs +++ b/ext/node/ops/v8.rs @@ -68,6 +68,7 @@ impl v8::ValueSerializerImpl for SerializerDelegate { let obj = self.obj(scope); let key = FastString::from_static("_getSharedArrayBufferId") .v8_string(scope) + .unwrap() .into(); if let Some(v) = obj.get(scope, key) { if let Ok(fun) = v.try_cast::() { @@ -89,6 +90,7 @@ impl v8::ValueSerializerImpl for SerializerDelegate { let obj = self.obj(scope); let key = FastString::from_static("_getDataCloneError") .v8_string(scope) + .unwrap() .into(); if let Some(v) = obj.get(scope, key) { let fun = v @@ -112,6 +114,7 @@ impl v8::ValueSerializerImpl for SerializerDelegate { let obj = self.obj(scope); let key = FastString::from_static("_writeHostObject") .v8_string(scope) + .unwrap() .into(); if let Some(v) = obj.get(scope, key) { if let Ok(v) = v.try_cast::() { @@ -240,6 +243,7 @@ impl v8::ValueDeserializerImpl for DeserializerDelegate { let obj = v8::Local::new(scope, &self.obj); let key = FastString::from_static("_readHostObject") .v8_string(scope) + .unwrap() .into(); let scope = &mut v8::AllowJavascriptExecutionScope::new(scope); if let Some(v) = obj.get(scope, key) { @@ -250,7 +254,8 @@ impl v8::ValueDeserializerImpl for DeserializerDelegate { Err(_) => { let msg = FastString::from_static("readHostObject must return an object") - .v8_string(scope); + .v8_string(scope) + .unwrap(); let error = v8::Exception::type_error(scope, msg); scope.throw_exception(error); return None;