From 61a0d3b4c49b693cec1dd9527e2b4772d4f3528d Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Thu, 21 Mar 2024 20:13:03 +0000 Subject: [PATCH] deps: V8: backport c4be0a97f981 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original commit message: Fix build with gcc12 - A number of erroneous flags have been added to BUILD.gn - wasm-init-expr.cc is creating an 8 byte buffer witch may be much smaller than max size_t output. We also need to make room for the `f` character and the terminating null character - inspector_protocol currently generates the following error ``` error: loop variable ‘json_in’ of type ‘const std::string&’ {aka ‘const std::__cxx11::basic_string&’} binds to a temporary constructed from type ‘const char* const’ ``` Change-Id: I1139899b2664e47d01ebc44f2e972fc4c0ec212d Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5331756 Reviewed-by: Matthias Liedtke Commit-Queue: Milad Farazmand Reviewed-by: Toon Verwaest Cr-Commit-Position: refs/heads/main@{#92615} Refs: https://github.com/v8/v8/commit/c4be0a97f981ce08bad854684c941e4c98647025 PR-URL: https://github.com/nodejs/node/pull/52183 Refs: https://github.com/v8/v8/commit/f8d5e576b814c92c39ec0cea80c21e4162270e12 Reviewed-By: Jiawen Geng Reviewed-By: Marco Ippolito Reviewed-By: Michaël Zasso Reviewed-By: Luigi Pinca PR-URL: https://github.com/nodejs/node/pull/51362 Reviewed-By: Matteo Collina Reviewed-By: Antoine du Hamel Reviewed-By: Rafael Gonzaga --- common.gypi | 2 +- deps/v8/BUILD.gn | 14 +++++++++++++ deps/v8/src/d8/d8.cc | 2 ++ deps/v8/src/wasm/function-compiler.cc | 9 ++++++--- .../inspector_protocol/crdtp/dispatch_test.cc | 20 ++++++++++--------- .../inspector_protocol/crdtp/json_test.cc | 19 +++++++++--------- 6 files changed, 44 insertions(+), 22 deletions(-) diff --git a/common.gypi b/common.gypi index 0e028e3bf97d97..108788e98a3f2c 100644 --- a/common.gypi +++ b/common.gypi @@ -37,7 +37,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.8', + 'v8_embedder_string': '-node.9', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/BUILD.gn b/deps/v8/BUILD.gn index 94f48cc4a7d892..133701b20ed9ba 100644 --- a/deps/v8/BUILD.gn +++ b/deps/v8/BUILD.gn @@ -1700,6 +1700,20 @@ config("toolchain") { # Fix build with older versions of GCC # Ported from v8 bazel: https://crrev.com/c/3368869 "-Wno-stringop-overflow", + + # Fix a number of bogus errors with gcc12 + # TODO(miladfarca): re-evaluate for future gcc upgrades + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111499 + "-Wno-stringop-overread", + + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104336 + "-Wno-restrict", + + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523 + "-Wno-array-bounds", + + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108517 + "-Wno-nonnull", ] } diff --git a/deps/v8/src/d8/d8.cc b/deps/v8/src/d8/d8.cc index eb804e52b18243..73a101f17430d6 100644 --- a/deps/v8/src/d8/d8.cc +++ b/deps/v8/src/d8/d8.cc @@ -3955,7 +3955,9 @@ V8_NOINLINE void FuzzerMonitor::UseAfterFree() { // Use-after-free caught by ASAN. std::vector* storage = new std::vector(3); delete storage; +#if defined(__clang__) USE(storage->at(1)); +#endif } V8_NOINLINE void FuzzerMonitor::UseOfUninitializedValue() { diff --git a/deps/v8/src/wasm/function-compiler.cc b/deps/v8/src/wasm/function-compiler.cc index 3591c747fad094..a44438bb1793e9 100644 --- a/deps/v8/src/wasm/function-compiler.cc +++ b/deps/v8/src/wasm/function-compiler.cc @@ -112,7 +112,7 @@ WasmCompilationResult WasmCompilationUnit::ExecuteFunctionCompilation( case ExecutionTier::kNone: UNREACHABLE(); - case ExecutionTier::kLiftoff: + case ExecutionTier::kLiftoff: { // The --wasm-tier-mask-for-testing flag can force functions to be // compiled with TurboFan, and the --wasm-debug-mask-for-testing can force // them to be compiled for debugging, see documentation. @@ -146,8 +146,8 @@ WasmCompilationResult WasmCompilationUnit::ExecuteFunctionCompilation( // TODO(wasm): We could actually stop or remove the tiering unit for this // function to avoid compiling it twice with TurboFan. V8_FALLTHROUGH; - - case ExecutionTier::kTurbofan: + } + case ExecutionTier::kTurbofan: { compiler::WasmCompilationData data(func_body); data.func_index = func_index_; data.wire_bytes_storage = wire_bytes_storage; @@ -167,6 +167,9 @@ WasmCompilationResult WasmCompilationUnit::ExecuteFunctionCompilation( detected); result.for_debugging = for_debugging_; break; + } + default: + UNREACHABLE(); } DCHECK(result.succeeded()); diff --git a/deps/v8/third_party/inspector_protocol/crdtp/dispatch_test.cc b/deps/v8/third_party/inspector_protocol/crdtp/dispatch_test.cc index faef35503bea18..504ff2548de5c2 100644 --- a/deps/v8/third_party/inspector_protocol/crdtp/dispatch_test.cc +++ b/deps/v8/third_party/inspector_protocol/crdtp/dispatch_test.cc @@ -169,10 +169,11 @@ TEST(DispatchableTest, MessageWithUnknownProperty) { } TEST(DispatchableTest, DuplicateMapKey) { - for (const std::string& json : - {"{\"id\":42,\"id\":42}", "{\"params\":null,\"params\":null}", - "{\"method\":\"foo\",\"method\":\"foo\"}", - "{\"sessionId\":\"42\",\"sessionId\":\"42\"}"}) { + const std::array jsons = { + {"{\"id\":42,\"id\":42}", "{\"params\":null,\"params\":null}", + "{\"method\":\"foo\",\"method\":\"foo\"}", + "{\"sessionId\":\"42\",\"sessionId\":\"42\"}"}}; + for (const std::string& json : jsons) { SCOPED_TRACE("json = " + json); std::vector cbor; ASSERT_TRUE(json::ConvertJSONToCBOR(SpanFrom(json), &cbor).ok()); @@ -185,11 +186,12 @@ TEST(DispatchableTest, DuplicateMapKey) { } TEST(DispatchableTest, ValidMessageParsesOK_NoParams) { - for (const std::string& json : - {"{\"id\":42,\"method\":\"Foo.executeBar\",\"sessionId\":" - "\"f421ssvaz4\"}", - "{\"id\":42,\"method\":\"Foo.executeBar\",\"sessionId\":\"f421ssvaz4\"," - "\"params\":null}"}) { + const std::array jsons = { + {"{\"id\":42,\"method\":\"Foo.executeBar\",\"sessionId\":" + "\"f421ssvaz4\"}", + "{\"id\":42,\"method\":\"Foo.executeBar\",\"sessionId\":\"f421ssvaz4\"," + "\"params\":null}"}}; + for (const std::string& json : jsons) { SCOPED_TRACE("json = " + json); std::vector cbor; ASSERT_TRUE(json::ConvertJSONToCBOR(SpanFrom(json), &cbor).ok()); diff --git a/deps/v8/third_party/inspector_protocol/crdtp/json_test.cc b/deps/v8/third_party/inspector_protocol/crdtp/json_test.cc index 7e25888faeb1f0..739eefcc73f882 100644 --- a/deps/v8/third_party/inspector_protocol/crdtp/json_test.cc +++ b/deps/v8/third_party/inspector_protocol/crdtp/json_test.cc @@ -704,15 +704,16 @@ using ContainerTestTypes = ::testing::Types, std::string>; TYPED_TEST_SUITE(ConvertJSONToCBORTest, ContainerTestTypes); TYPED_TEST(ConvertJSONToCBORTest, RoundTripValidJson) { - for (const std::string& json_in : { - "{\"msg\":\"Hello, world.\",\"lst\":[1,2,3]}", - "3.1415", - "false", - "true", - "\"Hello, world.\"", - "[1,2,3]", - "[]", - }) { + const std::array jsons = {{ + "{\"msg\":\"Hello, world.\",\"lst\":[1,2,3]}", + "3.1415", + "false", + "true", + "\"Hello, world.\"", + "[1,2,3]", + "[]", + }}; + for (const std::string& json_in : jsons) { SCOPED_TRACE(json_in); TypeParam json(json_in.begin(), json_in.end()); std::vector cbor;