inspector: fix inspector hung while disconnecting#8021
inspector: fix inspector hung while disconnecting#8021alexkozy wants to merge 1 commit intonodejs:masterfrom alexkozy:fix-hung-on-disconnect
Conversation
src/inspector_agent.cc
Outdated
There was a problem hiding this comment.
This seems prone to race condition. Variable is read and modified on 2 threads without any synchronization.
I wonder if it would be feasable to ::DispatchMessages when entering the main loop.
|
Improved base approach. Please take another look. |
src/inspector_agent.cc
Outdated
There was a problem hiding this comment.
This access is not guarded by a mutex...
If user during stepping make some actions (e.g. stepOver native call) that requests program break and disconnect DevTools frontend then AgentImpl won't be disconnected until other message from frontend. The root of issue: 1. Inspector requests program break. 2. User requests disconnect (e.g. refresh page with DevTools frontend). 3. On program break V8Inspector call runMessageLoopOnPause on V8NodeInspector. 4. Message loop will wait until next message from frontend. 5. After message Agent will be disconnected. We can dispatch all pending message on step 3 to solve a problem.
|
Uploaded another approach mentioned by @eugeneo in comment. |
|
LGTM |
| return; | ||
| terminated_ = false; | ||
| running_nested_loop_ = true; | ||
| agent_->DispatchMessages(); |
There was a problem hiding this comment.
Is this thread-safe? DispatchMessages() reads and writes dispatching_messages_ without holding any locks.
|
@bnoordhuis DispatchMessages is only called on the main thread (the thread where main V8 loop runs). That flag is only used in that function to prevent reentrance. |
|
I guess I don't understand your previous comment about thread safety then. |
|
In previous patches I use variable on IO thread (in ::OnRemoteIO) and on main thread (in ::DispatchMessages). IO thread can receives another disconnect message when main thread is processing previous one. |
|
LGTM |
|
I checked test results and it looks like failed tests don't relate to this change. Could you please try to rerun CI? |
|
sequential/test-crypto-timing-safe-equal is known flaky and due to be reverted, see #8225. parallel/test-fs-utimes failing on the ppcbe-ubuntu1404 buildbot is... interesting... but unlikely to be caused by this PR. |
|
The failures indeed look unrelated, but here's a new CI regardless: https://ci.nodejs.org/job/node-test-pull-request/3802/ |
If user make some actions during (e.g. stepOver native call) that requests program break and disconnect DevTools frontend then AgentImpl won't be disconnected until other message from frontend. The root of issue: 1. Inspector requests program break. 2. User requests disconnect (e.g. refresh page with DevTools frontend). 3. On program break V8Inspector call runMessageLoopOnPause on V8NodeInspector. 4. Message loop will wait until next message from frontend. 5. After message Agent will be disconnected. We can dispatch all pending message on step 3 to solve a problem. PR-URL: #8021 Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
|
New CI had different hiccups but plinux tests did pass. Landed as f7a23a2. |
If user make some actions during (e.g. stepOver native call) that requests program break and disconnect DevTools frontend then AgentImpl won't be disconnected until other message from frontend. The root of issue: 1. Inspector requests program break. 2. User requests disconnect (e.g. refresh page with DevTools frontend). 3. On program break V8Inspector call runMessageLoopOnPause on V8NodeInspector. 4. Message loop will wait until next message from frontend. 5. After message Agent will be disconnected. We can dispatch all pending message on step 3 to solve a problem. PR-URL: #8021 Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
Notable changes: * **buffer**: Fix regression introduced in v6.4.0 that prevented .write() at buffer end (Anna Henningsen) #8154 * **inspector**: * fix inspector hang while disconnecting (Aleksei Koziatinskii) #8021 * add support for uncaught exception (Aleksei Koziatinskii) #8043 * **meta**: add @joshgav to collaborators (Josh Gavant) #8146 * **repl**: Fix saving editor mode text in `.save` (Prince J Wesley) #8145 * ***Revert*** "**repl,util**: insert carriage returns in output" (Evan Lucas) #8143
Notable changes: * **buffer**: Fix regression introduced in v6.4.0 that prevented .write() at buffer end (Anna Henningsen) #8154 * **deps**: update V8 to 5.1.281.75 (Ali Ijaz Sheikh) #8054 * **inspector**: * fix inspector hang while disconnecting (Aleksei Koziatinskii) #8021 * add support for uncaught exception (Aleksei Koziatinskii) #8043 * **repl**: Fix saving editor mode text in `.save` (Prince J Wesley) #8145 * ***Revert*** "**repl,util**: insert carriage returns in output" (Evan Lucas) #8143 PR-URL: #8253
Notable changes: * **buffer**: Fix regression introduced in v6.4.0 that prevented .write() at buffer end (Anna Henningsen) #8154 * **deps**: update V8 to 5.1.281.75 (Ali Ijaz Sheikh) #8054 * **inspector**: * fix inspector hang while disconnecting (Aleksei Koziatinskii) #8021 * add support for uncaught exception (Aleksei Koziatinskii) #8043 * **repl**: Fix saving editor mode text in `.save` (Prince J Wesley) #8145 * ***Revert*** "**repl,util**: insert carriage returns in output" (Evan Lucas) #8143 PR-URL: #8253
Notable changes: * **buffer**: Fix regression introduced in v6.4.0 that prevented .write() at buffer end (Anna Henningsen) #8154 * **deps**: update V8 to 5.1.281.75 (Ali Ijaz Sheikh) #8054 * **inspector**: * fix inspector hang while disconnecting (Aleksei Koziatinskii) #8021 * add support for uncaught exception (Aleksei Koziatinskii) #8043 * **repl**: Fix saving editor mode text in `.save` (Prince J Wesley) #8145 * ***Revert*** "**repl,util**: insert carriage returns in output" (Evan Lucas) #8143 PR-URL: #8253
Checklist
make -j4 test(UNIX), orvcbuild test nosign(Windows) passesAffected core subsystem(s)
Description of change
If user during stepping make some actions (e.g. stepOver native call)
that requests program break and disconnect DevTools frontend then
AgentImpl won't be disconnected until other message from frontend.
The root of issue:
V8NodeInspector.
We need to ignore runMessageLoopOnPause on step 3 during disconnecting.