Skip to content

Commit 8feda0e

Browse files
committed
Fix hang in V8 debug builds
This is a partial cherry-pick of upstream commit v8/v8@8953e49478. Shows up in debug builds because of a buggy sanity check when computing relationships between command line flags. Example of the hang: #include "v8.h" #include "libplatform/libplatform.h" int main(void) { // works: v8::V8::SetFlagsFromString("--gc-global --noincremental-marking"); v8::V8::SetFlagsFromString("--gc-global"); v8::V8::SetFlagsFromString("--noincremental-marking"); v8::V8::InitializePlatform(v8::platform::NewDefaultPlatform().release()); v8::V8::Initialize(); // hangs in ComputeFlagListHash when defined(DEBUG) }
1 parent 309d2ef commit 8feda0e

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

libexec/extract-node

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ cd "${src}/node-v${version}"
3232
patch -p1 < "${top}"/patch/v8-std-is-trivially-destructible.patch
3333
patch -p1 < "${top}"/patch/v8-disable-madv-dontfork.patch
3434
patch -p1 < "${top}"/patch/v8-disable-pkey.patch
35+
patch -p1 < "${top}"/patch/v8-debug-flags-hang.patch

patch/v8-debug-flags-hang.patch

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
diff --git a/deps/v8/src/flags/flags-impl.h b/deps/v8/src/flags/flags-impl.h
2+
index d2d440c026..111b9b5b9c 100644
3+
--- a/deps/v8/src/flags/flags-impl.h
4+
+++ b/deps/v8/src/flags/flags-impl.h
5+
@@ -5,6 +5,8 @@
6+
#ifndef V8_FLAGS_FLAGS_IMPL_H_
7+
#define V8_FLAGS_FLAGS_IMPL_H_
8+
9+
+#include <unordered_set>
10+
+
11+
#include "src/base/macros.h"
12+
#include "src/base/optional.h"
13+
#include "src/base/vector.h"
14+
@@ -91,9 +93,12 @@ struct Flag {
15+
#ifdef DEBUG
16+
bool ImpliedBy(const void* ptr) const {
17+
const Flag* current = this->implied_by_ptr_;
18+
+ std::unordered_set<const Flag*> visited_flags;
19+
while (current != nullptr) {
20+
+ visited_flags.insert(current);
21+
if (current->PointsTo(ptr)) return true;
22+
current = current->implied_by_ptr_;
23+
+ if (visited_flags.contains(current)) break;
24+
}
25+
return false;
26+
}

0 commit comments

Comments
 (0)