v8/test/inspector
Simon Zünd 5242128f7a [debug] Fix crash in debug scope search
This CL fixes a crash when we build the scope chain after re-parsing
for Debugger.evaluateOnCallFrame.

The following script causes the crash:

class A {
  test(){
    debugger;
  }
  f = (x) => {}
}
let a = new A()
a.test()

The current scope search tries to be smart and descends deeper
into the scope tree based on source position. That is not a sound
approach as V8 doesn't guarantee that sibling scopes don't overlap.

In the above case V8 creates an instance initializer scope where
f is assigned (and the initializer scope is the parent scope for
the arrow function). The problem is that the initializer scope
uses the same source range as the class `A` itself, so when we
look for the scope for `test`, we descend wrongly into the
initializer scope and can't recover.

The solution is to not try and be too smart:
  - First, find the closure scope with a straight-up DFS.
  - Once we have that, descend from there and try to find the
    closest fitting scope around the break position.

R=bmeurer@chromium.org, jarin@chromium.org

Bug: chromium:1348186
Change-Id: Ic5e20c4d12b3d768f76a17367dc0f87bcc73763b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3807594
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Simon Zünd <szuend@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82216}
2022-08-05 09:53:54 +00:00
..
console [inspector] Rename console.scheduleTask to console.createTask 2022-07-27 06:09:27 +00:00
cpu-profiler [flags] Rename --opt to --turbofan 2022-05-03 12:10:30 +00:00
debugger [debug] Fix crash in debug scope search 2022-08-05 09:53:54 +00:00
heap-profiler Add snapshot test for JSWeakRef and FinalizationRegistry 2022-01-19 23:47:39 +00:00
regress [inspector] Introduce status result for Debugger.setScriptSource 2022-06-09 12:18:32 +00:00
runtime [error messages] Enhance the "unexpected identifier" error message 2022-07-12 06:44:27 +00:00
sessions [inspector] Correct location for inline scripts with sourceURL. 2021-12-29 15:39:22 +00:00
type-profiler [tests] Filter out non-existent methods in inspector tests 2020-01-17 12:21:29 +00:00
BUILD.gn Include test/inspector/regress to swarming 2021-07-29 08:00:47 +00:00
DEPS [test] Remove some unused includes (2) 2022-07-19 08:55:55 +00:00
DIR_METADATA Add DIR_METADATA files to v8. 2020-10-20 22:12:28 +00:00
frontend-channel.h [test] Remove some unused includes (2) 2022-07-19 08:55:55 +00:00
inspector-test.cc [test] Remove some unused includes (2) 2022-07-19 08:55:55 +00:00
inspector.status Reland "[riscv32] Add RISCV32 backend" 2022-08-04 12:47:44 +00:00
isolate-data.cc [test] Remove some unused includes (2) 2022-07-19 08:55:55 +00:00
isolate-data.h [test] Remove some unused includes (2) 2022-07-19 08:55:55 +00:00
json-parse-expected.txt
json-parse.js
OWNERS Add DIR_METADATA files to v8. 2020-10-20 22:12:28 +00:00
print-method-not-found-expected.txt [tests] Filter out non-existent methods in inspector tests 2020-01-17 12:21:29 +00:00
print-method-not-found.js [tests] Filter out non-existent methods in inspector tests 2020-01-17 12:21:29 +00:00
protocol-test.js [inspector] Add 'canBeRestarted' flag to CallFrames when debugger pauses 2022-04-20 12:40:34 +00:00
task-runner.cc [test] Remove some unused includes (2) 2022-07-19 08:55:55 +00:00
task-runner.h [test] Remove some unused includes (2) 2022-07-19 08:55:55 +00:00
tasks.cc Fix name collision of v8::internal::IsolateData 2021-08-25 08:45:53 +00:00
tasks.h Fix name collision of v8::internal::IsolateData 2021-08-25 08:45:53 +00:00
testcfg.py [test] Refactor testrunner (4) 2022-07-18 09:52:24 +00:00
utils.cc Reland "[include] Split out v8.h" 2021-08-24 13:08:55 +00:00
utils.h [test] Remove some unused includes (2) 2022-07-19 08:55:55 +00:00
wasm-inspector-test.js [wasm][debug] Provide WebAssembly Table entries to DevTools 2021-05-20 09:59:09 +00:00