Commit f79c3b51 authored by kozyatinskiy's avatar kozyatinskiy Committed by Commit bot

[inspector] entered into context before getPossibleBreakpoints call

getPossibleBreakpoints implementation can enforce function compilation which potentially can produce syntax error, we need to have a context to correctly report this error.

BUG=chromium:715334
R=dgozman@chromium.org

Review-Url: https://codereview.chromium.org/2851853002
Cr-Commit-Position: refs/heads/master@{#45003}
parent fc5079d3
......@@ -456,11 +456,15 @@ Response V8DebuggerAgentImpl::getPossibleBreakpoints(
}
auto it = m_scripts.find(scriptId);
if (it == m_scripts.end()) return Response::Error("Script not found");
std::vector<v8::debug::BreakLocation> v8Locations;
if (!it->second->getPossibleBreakpoints(
v8Start, v8End, restrictToFunction.fromMaybe(false), &v8Locations)) {
return Response::InternalError();
{
v8::HandleScope handleScope(m_isolate);
v8::Local<v8::Context> debuggerContext =
v8::debug::GetDebugContext(m_isolate);
v8::Context::Scope contextScope(debuggerContext);
v8::TryCatch tryCatch(m_isolate);
it->second->getPossibleBreakpoints(
v8Start, v8End, restrictToFunction.fromMaybe(false), &v8Locations);
}
*locations = protocol::Array<protocol::Debugger::BreakLocation>::create();
......
getPossibleBreakpoints should not crash during lazy compilation (crbug.com/715334)
{
method : Debugger.scriptParsed
params : {
endColumn : 21
endLine : 2
executionContextId : <executionContextId>
hasSourceURL : true
hash : FA2A959297747012766FE9C5006E7F522D88FA72
isLiveEdit : false
isModule : false
length : 52
scriptId : <scriptId>
sourceMapURL :
startColumn : 0
startLine : 0
url : test.js
}
}
{
id : <messageId>
result : {
locations : [
]
}
}
// Copyright 2017 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.
InspectorTest.log('getPossibleBreakpoints should not crash during lazy compilation (crbug.com/715334)');
InspectorTest.addScript(`
function test() { continue; }
//# sourceURL=test.js`);
(async function test() {
Protocol.Debugger.enable();
let script = await Protocol.Debugger.onceScriptParsed();
InspectorTest.logMessage(script);
let scriptId = script.params.scriptId;
Protocol.Debugger.onScriptFailedToParse(msg => {
InspectorTest.logMessage(msg);
if (msg.params.scriptId !== script.params.scriptId) {
InspectorTest.log('Failed script to parse event has different scriptId');
} else {
InspectorTest.log('One script is reported twice');
}
});
let response = await Protocol.Debugger.getPossibleBreakpoints({
start: {scriptId, lineNumber: 0, columnNumber: 0}});
InspectorTest.logMessage(response);
InspectorTest.completeTest();
})();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment