-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
inspector: fix inspector hung while disconnecting #8021
Conversation
@@ -438,6 +442,7 @@ void AgentImpl::OnRemoteDataIO(inspector_socket_t* socket, | |||
if (client_socket_ == socket) { | |||
String16 message(TAG_DISCONNECT, sizeof(TAG_DISCONNECT) - 1); | |||
client_socket_ = nullptr; | |||
disconnecting_ = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
@@ -286,6 +287,8 @@ class V8NodeInspector : public blink::V8Inspector { | |||
void runMessageLoopOnPause(int context_group_id) override { | |||
if (running_nested_loop_) | |||
return; | |||
if (agent_->incoming_disconnect_message_count_) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
@@ -288,6 +288,7 @@ class V8NodeInspector : public blink::V8Inspector { | |||
return; | |||
terminated_ = false; | |||
running_nested_loop_ = true; | |||
agent_->DispatchMessages(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.