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

src: fix segfault handling/RegisterSignalHandler #27775

Closed
wants to merge 4 commits into from

Conversation

addaleax
Copy link
Member

@addaleax addaleax commented May 20, 2019

src: do not use posix feature macro in node.h

This macro is only defined when building Node.js, so addons cannot
use it as a way of detecting feature availability.

src: reset SIGSEGV handler before crashing

Without this, we would re-enter the signal handler immediately
after re-raising the signal, leading to an infinite loop.

##### src: implement reset_handler for SIGSEGV handling

Otherwise, this makes RegisterSignalHandler() behave differently
for SIGSEGV than it does for all other signals.

Encoding the reset_handler bit as part of the function pointer value
is a bit of a hack, and may not work on all platforms.

(This commit can be left out, if people feel like it should be. It can also be replaced by not making the reset_handler argument part of the public API.)

src: forbid reset_handler for SIGSEGV handling

This is not easily implementable, and should be explicitly disallowed.

test: add addon tests for RegisterSignalHandler()

Ensure coverage for the different combinations of arguments.

Refs: #27246

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label May 20, 2019
@nodejs-github-bot

This comment has been minimized.

src/node.cc Show resolved Hide resolved
test/addons/register-signal-handler/binding.cc Outdated Show resolved Hide resolved
// with ALLOW_CRASHES set.
if (signal !== null && !process.env.ALLOW_CRASHES)
continue;
// reset_handler does not work on FreeBSD.
Copy link
Member

Choose a reason for hiding this comment

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

This can be removed when #27780 lands, I think?

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct, although I would feel more comfortable with (partially) backporting #27246 and this PR to v12.x (without enabling the WASM handler), while I wouldn’t necessarily do that with #27780 because it removes support for a platform, even if we have already officially stopped supporting it…

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@addaleax
Copy link
Member Author

@Trott thanks for re-starting CI, but the failures here are genuine and are not trivially solved – I’m still thinking about a nice solution, if I can’t come up with one then I’ll drop the corresponding parts of this PR…

@Trott Trott added the wip Issues and PRs that are still a work in progress. label Jun 1, 2019
@Trott
Copy link
Member

Trott commented Jun 1, 2019

@Trott thanks for re-starting CI, but the failures here are genuine and are not trivially solved – I’m still thinking about a nice solution, if I can’t come up with one then I’ll drop the corresponding parts of this PR…

Cool. I added the WIP label so I don't indiscriminately restart the CI again. Of course, remove it when appropriate.

@addaleax
Copy link
Member Author

addaleax commented Jun 9, 2019

Okay, updated with the third commit changed to forbid the SIGSEGV + reset_handler = true combination – I don’t see a good, cross-platform way to implement that, and fixing the issue here is actually pretty important, so I don’t want the PR lying around unused any longer.

@jasnell @bnoordhuis Could you take another look and make sure your reviews still stand?

@nodejs-github-bot

This comment has been minimized.

@addaleax addaleax added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. review wanted PRs that need reviews. and removed wip Issues and PRs that are still a work in progress. labels Jun 9, 2019
@nodejs-github-bot

This comment has been minimized.

@Trott
Copy link
Member

Trott commented Jun 13, 2019

This macro is only defined when building Node.js, so addons cannot
use it as a way of detecting feature availability.
Without this, we would re-enter the signal handler immediately
after re-raising the signal, leading to an infinite loop.
This is not easily implementable, and should be explicitly disallowed.
Ensure coverage for the different combinations of arguments.
@addaleax
Copy link
Member Author

Landed in 282e2f6...039cfdc

@addaleax addaleax closed this Jun 14, 2019
@addaleax addaleax deleted the fix-sigsegv branch June 14, 2019 17:29
addaleax added a commit that referenced this pull request Jun 14, 2019
This macro is only defined when building Node.js, so addons cannot
use it as a way of detecting feature availability.

PR-URL: #27775
Refs: #27246
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
addaleax added a commit that referenced this pull request Jun 14, 2019
Without this, we would re-enter the signal handler immediately
after re-raising the signal, leading to an infinite loop.

PR-URL: #27775
Refs: #27246
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
addaleax added a commit that referenced this pull request Jun 14, 2019
This is not easily implementable, and should be explicitly disallowed.

PR-URL: #27775
Refs: #27246
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
addaleax added a commit that referenced this pull request Jun 14, 2019
Ensure coverage for the different combinations of arguments.

PR-URL: #27775
Refs: #27246
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
@targos targos removed the review wanted PRs that need reviews. label Jul 2, 2019
@targos
Copy link
Member

targos commented Jul 2, 2019

@addaleax what was the reason for dont-land-on-v12.x?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants