[debug] Always return a valid PropertyDescriptor.

In DebugPropertyIterator::iterator() we were assuming that the call to
JSReceiver::GetOwnPropertyDescriptor() would always yield either an
exception or a valid property descriptor. But that's not guaranteed to
be the case (anymore), because JSReceiver::GetOwnPropertyDescriptor()
nowadays can chicken out with `false` for many different reasons.

Coincidentally the callsites to DebugPropertyIterator::iterator() are
already equipped to handle the case where of an empty property
descriptor, which is basically what we get out here. So this CL adjusts
the DebugPropertyIterator to return an empty descriptor in this case.

Fixed: chromium:1291240
Change-Id: I22a9d0cde2b2c6d3966a85478ed0b87fb4c5d232
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3736445
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81458}
This commit is contained in:
Benedikt Meurer 2022-06-30 08:12:53 +02:00 committed by V8 LUCI CQ
parent feccd6389b
commit 0de01928b7

View File

@ -146,6 +146,16 @@ v8::Maybe<v8::debug::PropertyDescriptor> DebugPropertyIterator::descriptor() {
if (did_get_descriptor.IsNothing()) {
return Nothing<v8::debug::PropertyDescriptor>();
}
if (!did_get_descriptor.FromJust()) {
return Just(v8::debug::PropertyDescriptor{
false, false, /* enumerable */
false, false, /* configurable */
false, false, /* writable */
v8::Local<v8::Value>(), /* value */
v8::Local<v8::Value>(), /* get */
v8::Local<v8::Value>(), /* set */
});
}
DCHECK(did_get_descriptor.FromJust());
return Just(v8::debug::PropertyDescriptor{
descriptor.enumerable(), descriptor.has_enumerable(),