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
fix dynamic linking int64 exceptions #21759
Conversation
@sbc100 If you look at the code for this, I added a one line check on exceptions thrown, as opposed to adding two function generators, one for bigint return and one for normal, as I think code size is a priority here right? I don't think there's a massive overhead given it is only in the exception thrown case anyway. Other than that, I think this is pretty uncontroversial; it would be good to get it in soon if possible; I'll submit a patch to it in pyodide until it's in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great to add a test for this. Ideally we would figure out which test already covers this case and extend it.
@sbc100 I added a test for this - it was quite fiddly to force the invoke call to happen, but the test fails before the fix and works after now.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting in the effort to make that test case. It looks like it it is indeed quite hard to reproduce!
I was wondering if there are any existing test that test this feature explictly.. I'll see if I can find one.
This is a backport of emscripten-core/emscripten#21759 It fixes a crash which happens when 1) An exception is thrown inside a function returning int64 2) The function is in a dynamic library and has been called through dynamic invocation.
It looks like we do have some existing tests for this part of the code:
At least these are the tests that fail when I disable the I wonder if we can extend/update these tests to cover this corner case? (I think |
Ha ha, you were right. Now I know how to trigger it, it took 3 line changes to that existing test. |
Incidentally, it appears empty throw statements don't always work in emscripten. I don't think that is necessarily a bad thing, as who does that... but it may be an inconsistency from standard C++ behaviour and thus another bug? |
@sbc100 I updated this to main again, can we merge it now? |
Currently if you dynamic link to something, and throw an exception in a function which returns int64, a javascript exception is thrown.
This is the same bug that was fixed in #15974 but in this case the dynamic linker is creating the invoke functions in javascript, rather than it being created in advance.
Fixes #21758