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
Segmentation Fault caused by uncatchable exception #344
Comments
HI @aidupl would mind to write the test as a NUnit test and send a PR instead a zip file? Thank you very much. |
Hello @viniciusjarina I was able to write two tests that cause a crash with a different outcome. Both caused by throwing multiple exceptions. |
I have also created an issue regarding this problem for the dotnet runtime and received an |
Thank you @aidupl I still didn't have time to investigate the issue. Is this also happening using WSL ? |
* Lua.Error() will call setjmp and this can cause a crash with CLR on Linux, it seems that calling the setjmp longjmp twice will crash on *nix systems. This should make this issue work a bit better: #344
@aidupl I don't think would be possible to workaround this issue without change the Lua source code. What I suggest is you to wrap your .NET calls into a single lua method and then use Like I did here https://github.com/NLua/NLua/pull/347/files#diff-8aa37412f4b48b161b9e772ef2a6e850R2751 Hopefully this patch #347 will help Mono/CLR to behave a bit better calling lua_error. |
* Lua.Error() will call setjmp and this can cause a crash with CLR on Linux, it seems that calling the setjmp longjmp twice will crash on *nix systems. This should make this issue work a bit better: #344
This change makes all C functions not throw their Lua errors directly, and instead makes them return it for a Lua wrapper to pick up and raise. By doing this, the issue of longjmp translation is bypassed/fixed on non-Windows platforms, as the errors are thrown and caught inside native Lua runtime code. Fixes NLua#344
While testing some Lua scripts using NLua I've encountered a strange behavior, possibly related to some bug with runtime stack. Here is a minimal example of the bug reproduction: LuaTest.zip
How the code works:
The Lua script is being loaded into a new Lua state and executed.
The
pcall
functions call TestClass methodexceptionMethod
which throws an exception. The exception should be caught by thepcall
and store the exception inerr
anderrMsg
variables.When executing the code on
Windows 10
everything works as expected. I can see the output of WriteLine:However the same code executed on
Ubuntu 18.04
ends with a "Segmentation fault (core dumped)" and no output.When running the app through the debugger on Ubuntu i can see:
I have tested the code on .NET Core versions 3.0.1 and 3.1 producing the same results on both
Windows 10
(works as expected) andUbuntu 18.04
(results in segmentation fault).I expect that throwing the exception (maybe) breaks the stack but I don't know how to test this further or fix it. Could it be a bug in the runtime implementation for linux?
The text was updated successfully, but these errors were encountered: