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

Is the register handler callback broken? #38

Open
binarykitchen opened this issue Apr 4, 2016 · 7 comments
Open

Is the register handler callback broken? #38

binarykitchen opened this issue Apr 4, 2016 · 7 comments

Comments

@binarykitchen
Copy link

    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?

@bfabec
Copy link

bfabec commented Feb 6, 2017

Also seeing the same.

@a-teammate
Copy link

same here

its always crashing in

nan_callbacks_12_inl.h (175): Nan::imp::FunctionCallbackWrapper

(well the stacktrace is even in the readme.. ^^)

@a-teammate
Copy link

a-teammate commented Jun 30, 2017

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:

  1. get the stacktrace into an array
  2. find a pthread replacement for windows

Solutions:

  1. could be taken from https://github.com/inexorgame-obsolete/platform/blob/master/include/windows/StackWalker%2B%2B/StackWalker.h
  2. 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)

@OmgImAlexis
Copy link

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 }));

@OmgImAlexis
Copy link

OmgImAlexis commented Jun 28, 2022

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 }));
});

@ddopson
Copy link
Owner

ddopson commented Jul 3, 2022

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.

@OmgImAlexis
Copy link

I'd be happy to help but I don't think if I know enough C++ as I'm mainly a node/python dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants