node-segfault-handler
node-segfault-handler copied to clipboard
Is the register handler callback broken?
SegfaultHandler.registerHandler('crash.log', function(signal, address, stack) {
console.log('here!')
})
SegfaultHandler.causeSegfault()
here!
is never printed. A bug or am I doing something wrong?
Also seeing the same.
same here
its always crashing in
nan_callbacks_12_inl.h (175): Nan::imp::FunctionCallbackWrapper
(well the stacktrace is even in the readme.. ^^)
Okay, its probably just bc im on windows.. furthermore @bfabec and @binarykitchen i just noticed the npm version is 1.0 which did not contain that handler.
@ddopson, @No9 are there any plans for version 1.1?
To get the overriden handler working on windows we need two things:
- get the stacktrace into an array
- find a pthread replacement for windows
Solutions:
- could be taken from https://github.com/inexorgame-obsolete/platform/blob/master/include/windows/StackWalker%2B%2B/StackWalker.h
- could be replace with std::mutex or the winapi maybe
I'd be willing to do this using the stdlib with c++11, since I don't know and neither want to use the windows specific mutex stuff. thoughts?
EDIT:
I just found about v8::Locker , see https://nodeaddons.com/how-not-to-access-node-js-from-c-worker-threads/:
Since we do not need simultaneous access from multiple threads for our crash handler (or do we @lavarsicious?) we could use that or cant we?
Imo we would only need it if: different native modules crash at the very same time (or other: in the time the callback is running the next native module crashes)
Still seems to be an issue.
The callback is never called.
import segfaultHandler from 'segfault-handler';
segfaultHandler.registerHandler('/var/log/unraid-api/crash.log', (signal, address, stack) => JSON.stringify({ signal, address, stack }));
As the application is crashed at that point I don't think stdout
is still hooked up so console.log
won't work.
I found if you use writeFileSync
you can write before the app completely stops like so.
This way we get both the human readable and the raw output.
import { writeFileSync } from 'fs';
import segfaultHandler from 'segfault-handler';
segfaultHandler.registerHandler('/var/log/app-name/crash.log', (signal, address, stack) => {
writeFileSync('/var/log/app-name/crash.json', JSON.stringify({ signal, address, stack }));
});
Hi, I need someone else to volunteer to maintain this module. I no longer have Node.js installed, and I haven't been paying attention to this space for many years. If someone would like to volunteer for this, please let me know.
I'd be happy to help but I don't think if I know enough C++ as I'm mainly a node/python dev.