Skip to content
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

win, watchdog: add flag to mark handler as disabled #10248

Closed
wants to merge 1 commit into from

Conversation

bzoz
Copy link
Contributor

@bzoz bzoz commented Dec 13, 2016

Checklist
  • make -j4 test (UNIX), or vcbuild test nosign (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

win, watchdog

Description of change

When calling process.exit from SIGHUP handler current code tries to remove CTRL-C handler (WinCtrlCHandlerRoutine) by calling SetConsoleCtrlHandler. This however leads to deadlock, since SetConsoleCtrlHandler blocks util all control handlers exits.

This commit adds flags that marks WinCtrlCHandlerRoutine as disabled instead of removing it.

When libuv/libuv#1168 lands, toogether it will fix #10165

cc: @addaleax @bnoordhuis

Adds flags that marks WinCtrlCHandlerRoutine as disabled instead of
removing it. Trying to remove the controller from the controller
handle itself leads to deadlock.
@bzoz bzoz added c++ Issues and PRs that require attention from people who are familiar with C++. windows Issues and PRs related to the Windows platform. labels Dec 13, 2016
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lts-watch-v6.x labels Dec 13, 2016
Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a suggestion

@@ -91,6 +91,7 @@ class SigintWatchdogHelper {
static void* RunSigintWatchdog(void* arg);
static void HandleSignal(int signum);
#else
bool watchdog_disabled_;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tbh, I would find this a bit easier to read as watchdog_enabled_ with the logic flipped around

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nicer, but with watchdog_disabled_ it is easier to tell if SigintWatchdogHelper::Start() is called for the first time and we have to register the handler or it is called after ::Stop() and we just have to flip the flag.

@joaocgreis
Copy link
Member

CI: https://ci.nodejs.org/job/node-test-commit/6817/

Landed in b2321c2 (per @bzoz request)

@joaocgreis joaocgreis closed this Dec 23, 2016
joaocgreis pushed a commit that referenced this pull request Dec 23, 2016
Adds flags that marks WinCtrlCHandlerRoutine as disabled instead of
removing it. Trying to remove the controller from the controller
handle itself leads to deadlock.

PR-URL: #10248
Reviewed-By: Anna Henningsen <[email protected]>
evanlucas pushed a commit that referenced this pull request Jan 3, 2017
Adds flags that marks WinCtrlCHandlerRoutine as disabled instead of
removing it. Trying to remove the controller from the controller
handle itself leads to deadlock.

PR-URL: #10248
Reviewed-By: Anna Henningsen <[email protected]>
evanlucas pushed a commit that referenced this pull request Jan 4, 2017
Adds flags that marks WinCtrlCHandlerRoutine as disabled instead of
removing it. Trying to remove the controller from the controller
handle itself leads to deadlock.

PR-URL: #10248
Reviewed-By: Anna Henningsen <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jan 23, 2017
Adds flags that marks WinCtrlCHandlerRoutine as disabled instead of
removing it. Trying to remove the controller from the controller
handle itself leads to deadlock.

PR-URL: #10248
Reviewed-By: Anna Henningsen <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jan 24, 2017
Adds flags that marks WinCtrlCHandlerRoutine as disabled instead of
removing it. Trying to remove the controller from the controller
handle itself leads to deadlock.

PR-URL: #10248
Reviewed-By: Anna Henningsen <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Jan 24, 2017
MylesBorins pushed a commit that referenced this pull request Jan 31, 2017
Adds flags that marks WinCtrlCHandlerRoutine as disabled instead of
removing it. Trying to remove the controller from the controller
handle itself leads to deadlock.

PR-URL: #10248
Reviewed-By: Anna Henningsen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handling of CTRL_CLOSE_EVENT/SIGHUP on Windows causes races and deadlocks
5 participants