Skip to content

Commit 215608f

Browse files
alexkozyCommit Bot
authored andcommitted
debug-evaluate: do not return JSGlobalObject instead of JSGlobalProxy
DebugEvaluate contains code since 2009 that bypasses JSGlobalProxy and returns JSGlobalObject when result of expression is global proxy. This behavior may be dangerous: - JSGlobalObject does not perform security checks, - some parts of V8 code do not ready for JSGlobalObject, e.g., SetHashAndUpdateProperties function will crash on DCHECK if we will try to store JSGlobalObject to map. At the same time it looks like there is no any valid use case for it. [email protected] Bug: none Cq-Include-Trybots: luci.chromium.try:linux_chromium_headless_rel;master.tryserver.blink:linux_trusty_blink_rel Change-Id: Ib0e35d5ae9ef47318c866e44c5c6856e34ed05a5 Reviewed-on: https://chromium-review.googlesource.com/1198764 Reviewed-by: Yang Guo <[email protected]> Commit-Queue: Aleksey Kozyatinskiy <[email protected]> Cr-Commit-Position: refs/heads/master@{#55550}
1 parent b4904de commit 215608f

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

src/debug/debug-evaluate.cc

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -140,25 +140,13 @@ MaybeHandle<Object> DebugEvaluate::Evaluate(
140140
Object);
141141

142142
Handle<Object> result;
143-
bool sucess = false;
143+
bool success = false;
144144
if (throw_on_side_effect) isolate->debug()->StartSideEffectCheckMode();
145-
sucess = Execution::Call(isolate, eval_fun, receiver, 0, nullptr)
146-
.ToHandle(&result);
145+
success = Execution::Call(isolate, eval_fun, receiver, 0, nullptr)
146+
.ToHandle(&result);
147147
if (throw_on_side_effect) isolate->debug()->StopSideEffectCheckMode();
148-
if (!sucess) {
149-
DCHECK(isolate->has_pending_exception());
150-
return MaybeHandle<Object>();
151-
}
152-
153-
// Skip the global proxy as it has no properties and always delegates to the
154-
// real global object.
155-
if (result->IsJSGlobalProxy()) {
156-
PrototypeIterator iter(isolate, Handle<JSGlobalProxy>::cast(result));
157-
// TODO(verwaest): This will crash when the global proxy is detached.
158-
result = PrototypeIterator::GetCurrent<JSObject>(iter);
159-
}
160-
161-
return result;
148+
if (!success) DCHECK(isolate->has_pending_exception());
149+
return success ? result : MaybeHandle<Object>();
162150
}
163151

164152
Handle<SharedFunctionInfo> DebugEvaluate::ContextBuilder::outer_info() const {

test/inspector/debugger/this-in-arrow-function-expected.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ This on callFrame:
9898
}
9999
This in evaluateOnCallFrame:
100100
{
101-
className : Object
102-
description : Object
101+
className : global
102+
description : global
103103
objectId : <objectId>
104104
type : object
105105
}
106-
Values equal: false
106+
Values equal: true
107107

0 commit comments

Comments
 (0)