Re: LuaJIT crashes on C++ exceptions in Visual Studio 32 bit mode

  • From: Peter Cawley <corsix@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 26 Apr 2016 00:47:47 +0100

In short, the following clause from http://luajit.org/extensions.html
is relevant:

Additionally, on Windows/x86 with SEH-based C++ exceptions: it's not
safe to throw a Lua error across any frames containing a C++ function
with any try/catch construct or using variables with (implicit)
destructors. This also applies to any functions which may be inlined
in such a function. It doesn't matter whether lua_error() is called
inside or outside of a try/catch or whether any object actually needs
to be destroyed: the SEH chain is corrupted and this will eventually
lead to the termination of the process.

This is a disappointing clause, and it seems ever so alluring that it
should be possible for this clause to be removed.

On Mon, Apr 25, 2016 at 10:51 PM, Peter Cawley <corsix@xxxxxxxxxx> wrote:

Taking those binaries and running them locally, the test runs just
fine - so there is something odd about those binaries in an Appveyor
environment rather than something odd about those binaries in every
environment. I'm tempted to suggest something along the lines of
https://www.appveyor.com/docs/how-to/rdp-to-build-worker - contact me
off-list if you'd like to explore that avenue.

On Mon, Apr 25, 2016 at 1:16 AM, Nagaev Boris <bnagaev@xxxxxxxxx> wrote:
On Mon, Apr 25, 2016 at 1:32 AM, Peter Cawley <corsix@xxxxxxxxxx> wrote:
I'm not having any luck reproducing the problem locally (despite using
hererocks.py, having MSVC 2015 - albeit build number 23506 rather than
23918 -, and targeting x86). Could you convince Appveyor to give out
lua.exe/lua51.dll/throw.dll as artifacts?

Hi Peter,

I uploaded directory "here" from AppVeyor to GitHub releases:
https://github.com/starius/luajit-vs32-throw/releases/download/1.0.5/here.tar.gz


On Sun, Apr 24, 2016 at 10:38 PM, Nagaev Boris <bnagaev@xxxxxxxxx> wrote:
On Mon, Apr 25, 2016 at 12:02 AM, Peter Cawley <corsix@xxxxxxxxxx> wrote:
I'm somewhat concerned by the following in your output log:
```
throw.cpp(5): warning C4530: C++ exception handler used, but unwind
semantics are not enabled. Specify /EHsc
```

Thank you, Peter!

I specified CFLAGS=/EHsc fixing the warning, but the crash still exists:

https://ci.appveyor.com/project/starius/luajit-vs32-throw/build/1.0.5/job/4weju0t18ae2asn7


On Sun, Apr 24, 2016 at 9:55 PM, Nagaev Boris <bnagaev@xxxxxxxxx> wrote:
Hi,

my C++ code throws C++ exceptions, so I wrap throwing code with
try-catch and throw Lua error in the catch block. It works in Rio Lua,
but it crashes in LuaJIT under the following conditions:

  * Visual Studio
  * 32 bit mode
  * multiple exceptions thrown, not one. It crashes after second 
exception.

I created a github project to demonstrate this problem:

https://github.com/starius/luajit-vs32-throw/

The log: 
https://ci.appveyor.com/project/starius/luajit-vs32-throw/build/job/ci3m1bf9cge8b4o4

--
Best regards,
Boris Nagaev





--


Best regards,
Boris Nagaev





--


Best regards,
Boris Nagaev


Other related posts: