Skip to content
forked from v8/v8

Commit

Permalink
[promises, async stack traces] Fix the case when the closure has run
Browse files Browse the repository at this point in the history
We were using the closure pointing to NativeContext as a marker that the
closure has run, but async stack trace code was confused about it.

Bug: chromium:1501326
Change-Id: I30d438f3b2e3fdd7562ea9a79dde4561ce9b0083
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5029996
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: Shu-yu Guo <syg@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/main@{#90949}
  • Loading branch information
marjakh authored and V8 LUCI CQ committed Nov 15, 2023
1 parent ae85166 commit bde3d36
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/execution/isolate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,13 @@ void CaptureAsyncStackTrace(Isolate* isolate, Handle<JSPromise> promise,
isolate);
builder->AppendPromiseCombinatorFrame(function, combinator);

// Now peak into the Promise.all() resolve element context to
if (IsNativeContext(*context)) {
// NativeContext is used as a marker that the closure was already
// called. We can't access the reject element context any more.
return;
}

// Now peek into the Promise.all() resolve element context to
// find the promise capability that's being resolved when all
// the concurrent promises resolve.
int const index =
Expand All @@ -1061,7 +1067,13 @@ void CaptureAsyncStackTrace(Isolate* isolate, Handle<JSPromise> promise,
context->native_context()->promise_all_settled(), isolate);
builder->AppendPromiseCombinatorFrame(function, combinator);

// Now peak into the Promise.allSettled() resolve element context to
if (IsNativeContext(*context)) {
// NativeContext is used as a marker that the closure was already
// called. We can't access the reject element context any more.
return;
}

// Now peek into the Promise.allSettled() resolve element context to
// find the promise capability that's being resolved when all
// the concurrent promises resolve.
int const index =
Expand All @@ -1079,7 +1091,13 @@ void CaptureAsyncStackTrace(Isolate* isolate, Handle<JSPromise> promise,
isolate);
builder->AppendPromiseCombinatorFrame(function, combinator);

// Now peak into the Promise.any() reject element context to
if (IsNativeContext(*context)) {
// NativeContext is used as a marker that the closure was already
// called. We can't access the reject element context any more.
return;
}

// Now peek into the Promise.any() reject element context to
// find the promise capability that's being resolved when any of
// the concurrent promises resolve.
int const index = PromiseBuiltins::kPromiseAnyRejectElementCapabilitySlot;
Expand Down

0 comments on commit bde3d36

Please sign in to comment.