-
Notifications
You must be signed in to change notification settings - Fork 121
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
Throwing inside a JS callback triggers a segfault #55
Comments
Interesting point. I suppose it should throw a C++ exception instead of crashing. Not much else it can do, if the callback is for example supposed to return an integer and throws instead. There's no reasonable value indicating an error to pass to C++. |
Would it be possible to emit an uncaughtexception on node |
Throwing an exception seems fair. I'm not sure if that's already implemented, but it would be nice to also catch C++ exceptions and relay them to the JS code. Something like (pseudocode):
That way, even if a callback throws, the exception will still be dispatched synchronously as one would expect, and could still be catched as usual on the JS side (which wouldn't be possible if nbind was simply emitting an |
This is true only if the callback stack contains some js stack frame upwards. Otherwise, there is no js place to catch the exception synchronously. Node js libraries usually emit the |
Can you test if the current |
It was already catching C++ exceptions on Node.js and turning the message into an equivalent JavaScript exception. Throwing C++ exceptions doesn't work on asm.js, but there the JavaScript exception already blows through any C++ code on the stack. Now JavaScript exceptions thrown by callbacks on Node.js throw a C++ This will cause very annoying issues on asm.js however. Since Emscripten doesn't properly support exceptions, no C++ destructors will get called for any objects on the C++ stack. |
It should, I'll test it soon... |
Cf title. Apparently, throwing from inside a JS callback triggers a segfault:
The text was updated successfully, but these errors were encountered: