Skip to content

src: add debug check for inspector uv_async_t - #25777

Closed
addaleax wants to merge 1 commit into
nodejs:masterfrom
addaleax:inspector-agent-init-check
Closed

src: add debug check for inspector uv_async_t#25777
addaleax wants to merge 1 commit into
nodejs:masterfrom
addaleax:inspector-agent-init-check

Conversation

@addaleax

Copy link
Copy Markdown
Member

Add a check to make sure start_io_thread_async is not
accidentally re-used or used when uninitialized.
(This is a bit of an odd check imo, but it helped me figure
out a real issue and it might do so again, so… why not?)

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

Add a check to make sure start_io_thread_async is not
accidentally re-used or used when uninitialized.
(This is a bit of an odd check imo, but it helped me figure
out a real issue and it might do so again, so… why not?)
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. inspector Issues and PRs related to the V8 inspector protocol. labels Jan 28, 2019
@addaleax

addaleax commented Jan 29, 2019

Copy link
Copy Markdown
Member Author

@addaleax addaleax added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Jan 29, 2019
@addaleax

Copy link
Copy Markdown
Member Author

Landed in 15b0ab1

@addaleax addaleax closed this Jan 30, 2019
@addaleax
addaleax deleted the inspector-agent-init-check branch January 30, 2019 22:56
addaleax added a commit that referenced this pull request Jan 30, 2019
Add a check to make sure start_io_thread_async is not
accidentally re-used or used when uninitialized.
(This is a bit of an odd check imo, but it helped me figure
out a real issue and it might do so again, so… why not?)

PR-URL: #25777
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
addaleax added a commit that referenced this pull request Jan 30, 2019
Add a check to make sure start_io_thread_async is not
accidentally re-used or used when uninitialized.
(This is a bit of an odd check imo, but it helped me figure
out a real issue and it might do so again, so… why not?)

PR-URL: #25777
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@targos targos mentioned this pull request Feb 14, 2019
codebytere added a commit to codebytere/node that referenced this pull request Sep 7, 2026
Two Environments with default flags alive at the same time (for
example the embedding.md example run on two threads, or two
`CommonEnvironmentSetup`s) aborted the process: `Agent::Start()` bound
one file-level static `uv_async_t` to the current Environment's loop
for every Environment with `kOwnsInspector`, which `kDefaultFlags`
implies, and CHECKed that nobody else had. Environments created one
after another did not abort, but each ran `StartDebugSignalHandler()`
again, which re-initialized the semaphore the watchdog waits on and
spawned another detached watchdog thread, leaking one thread per
Environment.

Give every Agent that asks for the debug signal handler its own async
handle, keep those Agents in a mutex-protected list that the watchdog
(or the Windows remote thread) walks, and set the watchdog up once per
process while still unblocking SIGUSR1 on each Environment's thread.
The handle is heap-allocated, closed by the cleanup hook or `~Agent()`,
whichever runs first, and freed by its close callback. A SIGUSR1 now
reaches every Environment that asked for the handler, and no longer
starts the inspector of one that passed `kNoStartDebugSignalHandler`.

Refs: nodejs#25777
Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
codebytere added a commit to codebytere/node that referenced this pull request Sep 9, 2026
Two Environments with default flags alive at the same time (for
example the embedding.md example run on two threads, or two
`CommonEnvironmentSetup`s) aborted the process: `Agent::Start()` bound
one file-level static `uv_async_t` to the current Environment's loop
for every Environment with `kOwnsInspector`, which `kDefaultFlags`
implies, and CHECKed that nobody else had. Environments created one
after another did not abort, but each ran `StartDebugSignalHandler()`
again, which re-initialized the semaphore the watchdog waits on and
spawned another detached watchdog thread, leaking one thread per
Environment.

Give every Agent that asks for the debug signal handler its own async
handle, keep those Agents in a mutex-protected list that the watchdog
(or the Windows remote thread) walks, and set the watchdog up once per
process while still unblocking SIGUSR1 on each Environment's thread.
The handle is heap-allocated, closed by the cleanup hook or `~Agent()`,
whichever runs first, and freed by its close callback. A SIGUSR1 now
reaches every Environment that asked for the handler, and no longer
starts the inspector of one that passed `kNoStartDebugSignalHandler`.

Refs: nodejs#25777
Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. c++ Issues and PRs that require attention from people who are familiar with C++. inspector Issues and PRs related to the V8 inspector protocol.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants