LuaJIT 2 crashes under FPC+Win64. SEH issue?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

LuaJIT 2 crashes under FPC+Win64. SEH issue?

denisgolovan
Hi all

Currently I am trying to make work attached code under Win64.
It uses LuaJIT 2 as drop-in replacement to Lua.

The code works fine under Linux32, Linux64, Win32, but not under Win64.
Under Win64 it crashes with unhandled exception like following:

An unhandled exception occurred at $0000000077D67D9D:
EControlC: Control-C hit
  $0000000077D67D9D

The same dll works fine under gcc/msvc complied project (luajit.exe interpreter which comes in box).

The idea of the attached code is following:
- try to calculate _invalid_ Lua code
- return Lua error (not exception).

The problem seems to have something to do with exception handling under Win64 as LuaJIT 2 using native exceptions in its dll.
But it does not mean that C exceptions should be catched by FPC.  I understand that's not possible.
lua_pcall should handle those internally (like under Linux64).

It looks like some issue in FPC prevents LuaJIT catch its own exception under Win64.

P.S. Tested under FPC svn rev. 23910
P.P.S. You can use https://github.com/malkia/ufo/blob/master/bin/Windows/x64/luajit.dll LuaJIT build under Win64. Just rename it to lua5.1.dll to comply with lua.pas.

--
Regards,
Denis Golovan
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

project1.lpr (848 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: LuaJIT 2 crashes under FPC+Win64. SEH issue?

Reinier Olislagers
On 2-3-2013 11:42, denisgolovan wrote:

> Hi all
>
> Currently I am trying to make work attached code under Win64.
> It uses LuaJIT 2 as drop-in replacement to Lua.
>
> The code works fine under Linux32, Linux64, Win32, but not under Win64.
> Under Win64 it crashes with unhandled exception like following:
>
> An unhandled exception occurred at $0000000077D67D9D:
> EControlC: Control-C hit
>   $0000000077D67D9D
>
> The same dll works fine under gcc/msvc complied project (luajit.exe interpreter which comes in box).
>
> The idea of the attached code is following:
> - try to calculate _invalid_ Lua code
> - return Lua error (not exception).
>
> The problem seems to have something to do with exception handling under Win64 as LuaJIT 2 using native exceptions in its dll.
> But it does not mean that C exceptions should be catched by FPC.  I understand that's not possible.
> lua_pcall should handle those internally (like under Linux64).
>
> It looks like some issue in FPC prevents LuaJIT catch its own exception under Win64.

Yep, it seems like issue is exception handling (similar to issue
http://bugs.freepascal.org/view.php?id=21581
etc)
Try compiling FPC with -dTEST_WIN64_SEH and try again...

To the devs: any news about Win64 SEH code progress?

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: LuaJIT 2 crashes under FPC+Win64. SEH issue?

denisgolovan
Thanks a ton.
Building FPC with -dTEST_WIN64_SEH makes the trick!

02.03.2013, 14:47, "Reinier Olislagers" <[hidden email]>:
> On 2-3-2013 11:42, denisgolovan wrote:

> Yep, it seems like issue is exception handling (similar to issue
> http://bugs.freepascal.org/view.php?id=21581
> etc)
> Try compiling FPC with -dTEST_WIN64_SEH and try again...
>
> To the devs: any news about Win64 SEH code progress?
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

--
Regards,
Denis Golovan
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: LuaJIT 2 crashes under FPC+Win64. SEH issue?

Marco van de Voort
In our previous episode, denisgolovan said:
> Building FPC with -dTEST_WIN64_SEH makes the trick!

Hmm, maybe it is slowly time to make this default in trunk?
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: LuaJIT 2 crashes under FPC+Win64. SEH issue?

Reinier Olislagers
On 2-3-2013 15:02, Marco van de Voort wrote:
> In our previous episode, denisgolovan said:
>> Building FPC with -dTEST_WIN64_SEH makes the trick!
>
> Hmm, maybe it is slowly time to make this defau

Or quickly ;)

Last I heard about it was in July 2012:
http://www.mail-archive.com/fpc-pascal@.../msg29010.html

Perhaps some improvements were made meanwhile?
(As for issue 1 in that post: doesn't Windows use a native linker nowadays?)

Thanks,
Reinier
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: LuaJIT 2 crashes under FPC+Win64. SEH issue?

Michael Van Canneyt
In reply to this post by Marco van de Voort


On Sat, 2 Mar 2013, Marco van de Voort wrote:

> In our previous episode, denisgolovan said:
>> Building FPC with -dTEST_WIN64_SEH makes the trick!
>
> Hmm, maybe it is slowly time to make this default in trunk?

+1

It will give it the necessary coverage.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Patch to enable Win64 SEH was: Re: LuaJIT 2 crashes under FPC+Win64. SEH issue?

Reinier Olislagers
In reply to this post by Marco van de Voort
On 2-3-2013 15:02, Marco van de Voort wrote:
> In our previous episode, denisgolovan said:
>> Building FPC with -dTEST_WIN64_SEH makes the trick!
>
> Hmm, maybe it is slowly time to make this default in trunk?


Uploaded a patch at
http://bugs.freepascal.org/view.php?id=24012

Please have a look, compiler people ;)

Thanks,
Reinier

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal