[d8] Handle exceptions on async_hooks.createHook
Before we assumed that no exception can be thrown when specifying a function to be used as an async hook, but that's not the case when e.g. the object passed to createHook is a proxy trapping on property access and the trap throws an exception. Bug: chromium:1337629 Change-Id: I7bd7893cd274afb6e642ed18aacb9e203f7fdd96 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3714233 Commit-Queue: Maya Lekova <mslekova@chromium.org> Reviewed-by: Camillo Bruni <cbruni@chromium.org> Cr-Commit-Position: refs/heads/main@{#81258}
This commit is contained in:
parent
643d69f75b
commit
1de7e24902
@ -134,12 +134,12 @@ Local<Object> AsyncHooks::CreateHook(
|
||||
|
||||
Local<Object> fn_obj = args[0].As<Object>();
|
||||
|
||||
#define SET_HOOK_FN(name) \
|
||||
Local<Value> name##_v = \
|
||||
fn_obj->Get(currentContext, String::NewFromUtf8Literal(isolate, #name)) \
|
||||
.ToLocalChecked(); \
|
||||
if (name##_v->IsFunction()) { \
|
||||
wrap->set_##name##_function(name##_v.As<Function>()); \
|
||||
#define SET_HOOK_FN(name) \
|
||||
MaybeLocal<Value> name##_maybe_func = \
|
||||
fn_obj->Get(currentContext, String::NewFromUtf8Literal(isolate, #name)); \
|
||||
Local<Value> name##_func; \
|
||||
if (name##_maybe_func.ToLocal(&name##_func) && name##_func->IsFunction()) { \
|
||||
wrap->set_##name##_function(name##_func.As<Function>()); \
|
||||
}
|
||||
|
||||
SET_HOOK_FN(init);
|
||||
|
11
test/mjsunit/async-hooks/regress-crbug-1337629.js
Normal file
11
test/mjsunit/async-hooks/regress-crbug-1337629.js
Normal file
@ -0,0 +1,11 @@
|
||||
// Copyright 2022 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.
|
||||
|
||||
const failing_proxy = new Proxy({}, new Proxy({}, {
|
||||
get() {
|
||||
throw "No trap should fire";
|
||||
}
|
||||
}));
|
||||
|
||||
assertThrows(() => async_hooks.createHook(failing_proxy));
|
Loading…
Reference in New Issue
Block a user