Repository navigation
deps: re-land V8 API interrupt JS check - #66740
christianaurichzm wants to merge 4 commits into
Conversation
Original commit message:
[inspector] Allow JS in pause notifications from API interrupts
Debugger.pause and OOM breaks are scheduled with RequestInterrupt(), so
handleProgramBreak() can run inside InvokeApiInterruptCallbacks() with
JavaScript execution disallowed. b36cf9f6ccd2 allowed JavaScript around
runMessageLoopOnPause(), but Debugger.paused is sent right before that
scope and Debugger.resumed right after it. An embedder channel that
delivers notifications to JavaScript on the same isolate, like the
in-process inspector.Session in Node.js, crashes with "Invoke in
DisallowJavascriptExecutionScope" when such a break happens.
Extend the existing scope over both notifications. d8's InspectorFrontend
opens its own AllowJavascriptExecutionScope, so no existing test covered
this; add a unittest with a channel that calls into JavaScript.
R=olivf@chromium.org, szuend@chromium.org
Refs: nodejs#65914
Bug: 40067940, 540137721
Change-Id: I0b60fb40cf9e753f7444d69ee8c40b4dd5d843ec
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/8459373
Reviewed-by: Simon ZΓΌnd <szuend@chromium.org>
Commit-Queue: Olivier FlΓΌckiger <olivf@chromium.org>
Reviewed-by: Olivier FlΓΌckiger <olivf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#110692}
V8 15.5 has no FunctionCallbackInfo::DataV2(), so the unittest reads
the session pointer through Data() instead.
Refs: v8/v8@35bd158
Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
Inspector messages for a main thread connection are dispatched from a V8 interrupt handler. Defer frontend messages in this case using a microtask. This preserves the existing timing contract for main thread inspector connections, where notifications are observable after a microtask checkpoint. Starting the inspector I/O thread and toggling network tracking can also call into JS from an interrupt. Signed-off-by: deepak1556 <hop2deep@gmail.com> Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
Signed-off-by: deepak1556 <hop2deep@gmail.com> Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
Debugger.pause breaks from an API interrupt, and V8 sends Debugger.paused and Debugger.resumed to every session from there. An in-process inspector.Session receives them by calling into JavaScript, which aborts with "Invoke in DisallowJavascriptExecutionScope" unless V8 allows JavaScript around both notifications. Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
|
Review requested:
|
|
@legendecas @joyeecheung since you reviewed #65397, could you take a look at the re-land when you get a chance? It also needs a node-test-commit-v8-linux run, since that is what caught the futex failure last time. Thanks! |
Codecov Reportβ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #66740 +/- ##
==========================================
- Coverage 90.48% 90.48% -0.01%
==========================================
Files 791 791
Lines 277204 277250 +46
Branches 53311 53314 +3
==========================================
+ Hits 250841 250871 +30
- Misses 16760 16786 +26
+ Partials 9603 9593 -10
π New features to boost your workflow:
|
|
Oh another case found,
Rather than deferring |
|
Note that we are drafting a new policy for updating V8 in Node.js - for V8 commit backports that are justified to be fast tracked and do not have to wait for the regular V8 upgrade, it's better to target release staging branches, instead of main: #66710 |
This re-lands #65397 together with the V8 fix for the inspector crash it exposed.
#65907 reverted it because
debugger/debug/futex-reentrant-waitfailed onnode-test-commit-v8-linux. That test depends on https://chromium-review.googlesource.com/c/v8/v8/+/8086043, which V8 14.6 didn't have.deps/v8is on 15.5 now, which has it.The check also made
test-inspector-multisession-wsabort withInvoke in DisallowJavascriptExecutionScope(nodejs/reliability#1654). When V8 pauses from an API interrupt, it sentDebugger.pausedandDebugger.resumedoutside theAllowJavascriptExecutionScopeit opens for the pause loop, and an in-processinspector.Sessionhandles both in JavaScript. v8/v8@35bd1582fe0a fixes that, and the first commit backports it. V8 15.5 has noFunctionCallbackInfo::DataV2(), so the unittest usesData()instead.@deepak1556's two commits are unchanged apart from a conflict with #65877 in
src/inspector_agent.{cc,h}. As in #65397, messages for an in-processinspector.Sessionthat arrive while Node handles another client's message in an interrupt are delivered at the next microtask checkpoint instead of synchronously.test-inspector-pause-with-js-sessionaborts 5/5 without the V8 fix and passes 100/100 with it.test-inspector-multisession-wspasses 100/100 as well, but it also passed without the fix here, so it only hits the crash by timing.make lint,parallelandsequentialpass on Linux x64. This should also get anode-test-commit-v8-linuxrun.Refs: #65397
Refs: #65907
Refs: #65914
Refs: nodejs/reliability#1654