Skip to content

Commit 9527a2a

Browse files
addaleaxBethGriggs
authored andcommitted
deps: V8: cherry-pick e06ace6b5cdb
Original commit message: [api] Fix empty Maybe crash in GetRealNamedPropertyAttributes `Object::GetRealNamedPropertyAttributes()` can crash if an empty `Maybe` is returned by `JSReceiver::GetPropertyAttributes()` because it was not checking for that. Fix that. Refs: #34606 Change-Id: Ic83f904ba7134786bcd8f786eb2ce98adb4fea1e Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2335057 Commit-Queue: Leszek Swirski <[email protected]> Reviewed-by: Leszek Swirski <[email protected]> Cr-Commit-Position: refs/heads/master@{#69258} Refs: v8/v8@e06ace6 PR-URL: #34673 Fixes: #34606 Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 8766b5b commit 9527a2a

File tree

3 files changed

+50
-6
lines changed

3 files changed

+50
-6
lines changed

common.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.12',
39+
'v8_embedder_string': '-node.13',
4040

4141
##### V8 defaults for Node.js #####
4242

deps/v8/src/api/api.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4653,9 +4653,9 @@ Maybe<PropertyAttribute>
46534653
v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(
46544654
Local<Context> context, Local<Name> key) {
46554655
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
4656-
ENTER_V8_NO_SCRIPT(isolate, context, Object,
4657-
GetRealNamedPropertyAttributesInPrototypeChain,
4658-
Nothing<PropertyAttribute>(), i::HandleScope);
4656+
ENTER_V8(isolate, context, Object,
4657+
GetRealNamedPropertyAttributesInPrototypeChain,
4658+
Nothing<PropertyAttribute>(), i::HandleScope);
46594659
i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
46604660
if (!self->IsJSObject()) return Nothing<PropertyAttribute>();
46614661
i::Handle<i::Name> key_obj = Utils::OpenHandle(*key);
@@ -4668,6 +4668,7 @@ v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(
46684668
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
46694669
Maybe<i::PropertyAttributes> result =
46704670
i::JSReceiver::GetPropertyAttributes(&it);
4671+
has_pending_exception = result.IsNothing();
46714672
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute);
46724673
if (!it.IsFound()) return Nothing<PropertyAttribute>();
46734674
if (result.FromJust() == i::ABSENT) return Just(None);
@@ -4692,14 +4693,15 @@ MaybeLocal<Value> v8::Object::GetRealNamedProperty(Local<Context> context,
46924693
Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes(
46934694
Local<Context> context, Local<Name> key) {
46944695
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
4695-
ENTER_V8_NO_SCRIPT(isolate, context, Object, GetRealNamedPropertyAttributes,
4696-
Nothing<PropertyAttribute>(), i::HandleScope);
4696+
ENTER_V8(isolate, context, Object, GetRealNamedPropertyAttributes,
4697+
Nothing<PropertyAttribute>(), i::HandleScope);
46974698
i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
46984699
i::Handle<i::Name> key_obj = Utils::OpenHandle(*key);
46994700
i::LookupIterator::Key lookup_key(isolate, key_obj);
47004701
i::LookupIterator it(isolate, self, lookup_key, self,
47014702
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
47024703
auto result = i::JSReceiver::GetPropertyAttributes(&it);
4704+
has_pending_exception = result.IsNothing();
47034705
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute);
47044706
if (!it.IsFound()) return Nothing<PropertyAttribute>();
47054707
if (result.FromJust() == i::ABSENT) {

deps/v8/test/cctest/test-api.cc

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11959,6 +11959,48 @@ THREADED_TEST(VariousGetPropertiesAndThrowingCallbacks) {
1195911959
CHECK(result.IsEmpty());
1196011960
}
1196111961

11962+
THREADED_TEST(GetRealNamedPropertyAttributes_With_Proxy) {
11963+
LocalContext context;
11964+
HandleScope scope(context->GetIsolate());
11965+
11966+
{
11967+
Local<Object> proxy =
11968+
CompileRun(
11969+
"new Proxy({ p: 1 }, { getOwnPropertyDescriptor: _ => { "
11970+
" throw new Error('xyz'); } });")
11971+
.As<Object>();
11972+
TryCatch try_catch(context->GetIsolate());
11973+
v8::Maybe<v8::PropertyAttribute> result =
11974+
proxy->GetRealNamedPropertyAttributes(context.local(), v8_str("p"));
11975+
CHECK(result.IsNothing());
11976+
CHECK(try_catch.HasCaught());
11977+
CHECK(try_catch.Exception()
11978+
.As<Object>()
11979+
->Get(context.local(), v8_str("message"))
11980+
.ToLocalChecked()
11981+
->StrictEquals(v8_str("xyz")));
11982+
}
11983+
11984+
{
11985+
Local<Object> proxy =
11986+
CompileRun(
11987+
"Object.create("
11988+
" new Proxy({ p: 1 }, { getOwnPropertyDescriptor: _ => { "
11989+
" throw new Error('abc'); } }))")
11990+
.As<Object>();
11991+
TryCatch try_catch(context->GetIsolate());
11992+
v8::Maybe<v8::PropertyAttribute> result =
11993+
proxy->GetRealNamedPropertyAttributesInPrototypeChain(context.local(),
11994+
v8_str("p"));
11995+
CHECK(result.IsNothing());
11996+
CHECK(try_catch.HasCaught());
11997+
CHECK(try_catch.Exception()
11998+
.As<Object>()
11999+
->Get(context.local(), v8_str("message"))
12000+
.ToLocalChecked()
12001+
->StrictEquals(v8_str("abc")));
12002+
}
12003+
}
1196212004

1196312005
static void ThrowingCallbackWithTryCatch(
1196412006
const v8::FunctionCallbackInfo<v8::Value>& args) {

0 commit comments

Comments
 (0)