Skip to content

nodejs C++ addon exception catch #2169

Closed

Description

@wanghui-andy

i have written a C++ addon and compile it into *.node file, somtimes it crashes, so i want to catch the exception, what i do now is tring to write dump file with windows API in my C++ file, but when i run my program, the exception-catch callback function never be triggered. What confuses me is that when i use the same code to catch exception and write dump file in *.dll file, it works well, what should i do if i want to write dump file correctly when my C++ addon crashes? Thanks!

Activity

  1. transferred this issue fromnodejs/nodeon Sep 6, 2019
  2. gireeshpunathil commented on Dec 23, 2019

    @gireeshpunathil
    Member

    @AndyWangGo - is this still an issue?

    What I understand from your explanation is: when you tested your code (that is shown in the linked issues) in a stand alone program it works (able to catch signals and produce valid minidumps), but does not work when built as a node.js addon.

    Is my understanding right?

  3. wanghui-andy commented on Dec 31, 2019

    @wanghui-andy
    Author
  4. gireeshpunathil commented on Dec 31, 2019

    @gireeshpunathil
    Member

    https://github.com/libuv/libuv/blob/2c279504f92a7ab1fc54c85ec36272722198a77e/src/win/core.c#L178-L179

    I think it has to do with this setting in libuv, which tells windows to not take the normal route for structured exception handling. cc @nodejs/libuv for an expert opinion.

  5. gireeshpunathil commented on Jan 2, 2020

    @gireeshpunathil
    Member

    @AndyWangGo - alternatively, if you are / can build node from source, can you comment out the line mentioned above and see what happens?

  6. wanghui-andy commented on Jan 2, 2020

    @wanghui-andy
    Author

    @AndyWangGo - alternatively, if you are / can build node from source, can you comment out the line mentioned above and see what happens?

    Thanks for your kind reply. I see what you mean in the last reply, but i do not build libuv to use it, so i can not modify the libuv source code. Is there any other way to change the setting in libuv such as calling API?

  7. gireeshpunathil commented on Jan 2, 2020

    @gireeshpunathil
    Member

    @AndyWangGo - I don't think so (i.e, an API call to suppress this setting).

    Can you do:

    SetErrorMode(0);

    in your addon's entry point function (the module registration entry point) and see what happens?

  8. wanghui-andy commented on Jan 2, 2020

    @wanghui-andy
    Author

    happens

    ok, i'll try and see what will happen.

  9. PoojaDurgad commented on Sep 25, 2020

    @PoojaDurgad

    @AndyWangGo - is this still outstanding?

  10. PoojaDurgad commented on Oct 26, 2020

    @PoojaDurgad

    inactive. closing!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions