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

Discussion: Interest in segfault-handler #7059

Closed
No9 opened this issue May 30, 2016 · 6 comments
Closed

Discussion: Interest in segfault-handler #7059

No9 opened this issue May 30, 2016 · 6 comments
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. feature request Issues that request new features to be added to Node.js.

Comments

@No9
Copy link
Member

No9 commented May 30, 2016

Hey @nodejs/ctc
@fresheneesz raised an issue on segfault handler asking if we had discussed handing it over to core ddopson/node-segfault-handler#42 as the info you get for native module failures is a little more informative than the default in node.js.

I am not aware if it has been discussed previously but if it's something of interest then it would be great to make it happen

@bnoordhuis
Copy link
Member

See #6734. It doesn't print backtraces on SIGSEGV or other fatal signals though, doing that from a signal handler is unsafe.

@mscdex mscdex added c++ Issues and PRs that require attention from people who are familiar with C++. feature request Issues that request new features to be added to Node.js. labels May 30, 2016
@fresheneesz
Copy link

@bnoordhuis Unsafe: how so?

@bnoordhuis
Copy link
Member

There are only a limited number of things you are allowed to do in a signal handler, see the list of async-signal-safe functions in man 7 signal. Things like calling printf, malloc or dladdr are not on the list.

@fresheneesz
Copy link

@bnoordhuis Is that a limitation of v8 or something more fundamental?

@bnoordhuis
Copy link
Member

It's a pretty fundamental limitation. Think of it like this: a signal arrives at an arbitrary time where the program can be in any state, including inconsistent or bad states.

As an example: printf and malloc generally grab locks to ensure proper synchronization. What happens when a signal arrives when the main program is inside a critical section and you try to re-enter that critical section again from the signal handler? Deadlock, data races, data corruption and segfaults are all possible.

@No9
Copy link
Member Author

No9 commented May 31, 2016

Thanks @bnoordhuis this is really useful so thanks for taking the time.
I think the usecase of being able to get rapid feedback during the development of a native module is valid but your insights into why you wouldn't want to do this in production are great.
I'm closing this and I will update the docs to mention the issues with it and recommend it for certain dev scenarios only.

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++. feature request Issues that request new features to be added to Node.js.
Projects
None yet
Development

No branches or pull requests

4 participants