Skip to content

Commit

Permalink
deps: V8: partially cherry-pick 8953e49478
Browse files Browse the repository at this point in the history
Very partial cherry-pick of upstream commit v8/v8@8953e49478 that fixes
a hang that 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)
    }

PR-URL: #55274
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
bnoordhuis authored and targos committed Oct 7, 2024
1 parent 0999949 commit 2f65b3f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions deps/v8/src/flags/flags-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#ifndef V8_FLAGS_FLAGS_IMPL_H_
#define V8_FLAGS_FLAGS_IMPL_H_

#include <unordered_set>

#include "src/base/macros.h"
#include "src/base/optional.h"
#include "src/base/vector.h"
Expand Down Expand Up @@ -91,9 +93,12 @@ struct Flag {
#ifdef DEBUG
bool ImpliedBy(const void* ptr) const {
const Flag* current = this->implied_by_ptr_;
std::unordered_set<const Flag*> visited_flags;
while (current != nullptr) {
visited_flags.insert(current);
if (current->PointsTo(ptr)) return true;
current = current->implied_by_ptr_;
if (visited_flags.contains(current)) break;
}
return false;
}
Expand Down

0 comments on commit 2f65b3f

Please sign in to comment.