debug: LoadLookupSlot should initialize receiver for modules..

.. otherwise V8 crashes on attempt to use imported function as part
of expression passed to Debugger.evaluateOnCallFrame.

R=neis@chromium.org

Bug: chromium:878029
Cq-Include-Trybots: luci.chromium.try:linux_chromium_headless_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I61b837f5c7b84a80d91a9cdaaac0422a24aa1620
Reviewed-on: https://chromium-review.googlesource.com/1241475
Reviewed-by: Georg Neis <neis@chromium.org>
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56216}
This commit is contained in:
Alexey Kozyatinskiy 2018-09-24 15:45:25 -07:00 committed by Commit Bot
parent 72131a74ef
commit e439681323
3 changed files with 44 additions and 0 deletions

View File

@ -801,6 +801,8 @@ MaybeHandle<Object> LoadLookupSlot(Isolate* isolate, Handle<String> name,
if (isolate->has_pending_exception()) return MaybeHandle<Object>();
if (!holder.is_null() && holder->IsModule()) {
Handle<Object> receiver = isolate->factory()->undefined_value();
if (receiver_return) *receiver_return = receiver;
return Module::LoadVariable(isolate, Handle<Module>::cast(holder), index);
}
if (index != Context::kNotFound) {

View File

@ -0,0 +1,11 @@
Evaluate at first line of module should not crash
{
id : <messageId>
result : {
result : {
description : 0
type : number
value : 0
}
}
}

View File

@ -0,0 +1,31 @@
// 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.
const {session, contextGroup, Protocol} =
InspectorTest.start('Evaluate at first line of module should not crash');
const utilsModule = `export function identity(value) {
return value;
}`;
const mainModule = `import {identity} from 'utils';
console.log(identity(0));`;
(async function test() {
Protocol.Debugger.enable();
Protocol.Debugger.setBreakpointByUrl({
lineNumber: 1,
url: 'main'
});
contextGroup.addModule(utilsModule, 'utils');
contextGroup.addModule(mainModule, 'main');
const { params: { callFrames } } = await Protocol.Debugger.oncePaused();
const result = await Protocol.Debugger.evaluateOnCallFrame({
callFrameId: callFrames[0].callFrameId,
expression: 'identity(0)'
});
InspectorTest.logMessage(result);
InspectorTest.completeTest();
})()