Commit 2a08adbb authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[async] Gracefully handle suspended generators.

With async_hooks it's also possible that the "current microtask" is an
await task, whose generator is already suspended, when there's an
exception thrown in the AFTER callback. In that case we cannot build
a meaningful async stack trace.

Bug: chromium:897406, v8:7522
Change-Id: I682dc1fc3ebb1864e1c2061041ff99ced0313f0c
Reviewed-on: https://chromium-review.googlesource.com/c/1292057Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56839}
parent 1a651762
......@@ -768,22 +768,22 @@ Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSReceiver> error_object,
this);
Handle<JSGeneratorObject> generator_object(
JSGeneratorObject::cast(context->extension()), this);
CHECK(generator_object->is_executing());
if (generator_object->IsJSAsyncFunctionObject()) {
Handle<JSAsyncFunctionObject> async_function_object =
Handle<JSAsyncFunctionObject>::cast(generator_object);
Handle<JSPromise> promise(async_function_object->promise(), this);
CaptureAsyncStackTrace(this, promise, &builder);
} else {
Handle<JSAsyncGeneratorObject> async_generator_object =
Handle<JSAsyncGeneratorObject>::cast(generator_object);
Handle<AsyncGeneratorRequest> async_generator_request(
AsyncGeneratorRequest::cast(async_generator_object->queue()),
this);
Handle<JSPromise> promise(
JSPromise::cast(async_generator_request->promise()), this);
CaptureAsyncStackTrace(this, promise, &builder);
if (generator_object->is_executing()) {
if (generator_object->IsJSAsyncFunctionObject()) {
Handle<JSAsyncFunctionObject> async_function_object =
Handle<JSAsyncFunctionObject>::cast(generator_object);
Handle<JSPromise> promise(async_function_object->promise(), this);
CaptureAsyncStackTrace(this, promise, &builder);
} else {
Handle<JSAsyncGeneratorObject> async_generator_object =
Handle<JSAsyncGeneratorObject>::cast(generator_object);
Handle<AsyncGeneratorRequest> async_generator_request(
AsyncGeneratorRequest::cast(async_generator_object->queue()),
this);
Handle<JSPromise> promise(
JSPromise::cast(async_generator_request->promise()), this);
CaptureAsyncStackTrace(this, promise, &builder);
}
}
} else {
// The {promise_reaction_job_task} doesn't belong to an await (or
......
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --async-stack-traces --expose-async-hooks
async_hooks.createHook({
after() { throw new Error(); }
}).enable();
(async function() {
await 1;
await 1;
})();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment