Lua compilation and exceptions

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

Lua compilation and exceptions

Szymon Gatner
Hi,

should Lua be built as C++ to play nicely with luabind error handling?

>From http://lua-users.org/wiki/BuildingLua:
"By default if lua 5.1 or later is compiled as C++, it will use C++
exceptions to unwind the stack rather than longjmp/setjmp, though this
is configurable (at compile time). See luaconf.h near
LUAI_THROW/LUAI_TRY for a discussion of this."

I am rather confused how this fits into luabind's exception handling.
For example, docs say that:
"If any of the functions you register throws an exception when called,
that exception will be caught by luabind and converted to an error
string and lua_error() will be invoked."

Since lua_error() behaves differently depending on how Lua was build
(longjump in C, exceptions in C++) which is the correct way to build
Lua when used with luabind?

Regards,
Szymon Gatner

------------------------------------------------------------------------------
What You Don't Know About Data Connectivity CAN Hurt You
This paper provides an overview of data connectivity, details
its effect on application quality, and explores various alternative
solutions. http://p.sf.net/sfu/progress-d2d
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Lua compilation and exceptions

James Porter-2
On 3/4/2011 2:48 PM, Szymon Gatner wrote:
> should Lua be built as C++ to play nicely with luabind error handling?

As I recall (and it's been a while), neither way is particularly good,
though both will "work". Even though Lua can use C++ exceptions for
stack unwinding, not all of the internal functions are meant to have
exceptions be thrown through them. In practice, it doesn't matter too
much, but I think it causes issues with the Lua instance's counter for
the stack depth.

There are patches for Lua that make this totally safe, but I don't think
they ever got into Lua proper.

Some (all?) of this may be irrelevant at this point though, so take what
I say with a grain of salt.

- Jim


------------------------------------------------------------------------------
What You Don't Know About Data Connectivity CAN Hurt You
This paper provides an overview of data connectivity, details
its effect on application quality, and explores various alternative
solutions. http://p.sf.net/sfu/progress-d2d
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user