Acceptable actions to take inside a C++ addon's initialization function?

25 views
Skip to first unread message

Ryan Cole

unread,
Nov 10, 2012, 7:25:34 PM11/10/12
to nod...@googlegroups.com
I'm getting a seg fault core dump in a simple module. I can eliminate the seg fault if I comment out a ThrowException call in the initialization function.

My code: https://gist.github.com/4053133 (line #28)

Things makes me wonder, what are the acceptable actions to take inside of this initialize function? Is this seg fault occurring because I'm throwing an exception while loading the module? Obviously I need to figure out why the function call on line 27 is failing, so that I can avoid that error condition all together. How should I handle initialization failures, though?

Thanks,
Ryan

Nathan Rajlich

unread,
Nov 10, 2012, 7:35:26 PM11/10/12
to nod...@googlegroups.com
Generally you just set functions and other properties on the provided
"target" object (which end up being the native module's exports).
Throwing from within an the initialization function, it'd say, is
undefined behavior.

However, it may be possible to catch those errors and act
appropriately, but I haven't checked that code yet to verify.
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
Reply all
Reply to author
Forward
0 new messages