lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I agree that there's not much that Lua can do. However it could have a
function pointer to a C error handler, which is just enough customization
for the program that I'm working on. This way, the host application has an
opportunity to exit in its own way. Also, it may be a context in which Lua's
memory corruption does not affect the host application, and in that case the
host application could terminate and restart Lua or something like that.

Eric

> -----Original Message-----
> From: owner-lua-l@tecgraf.puc-rio.br
> [mailto:owner-lua-l@tecgraf.puc-rio.br]On Behalf Of Luiz Henrique de
> Figueiredo
> Sent: Monday, November 19, 2001 5:23 AM
> To: Multiple recipients of list
> Subject: Re: customizable Lua "panic" behavior
>
>
> >When Lua gets into a reall bad error (one for which no error handler is
> >available) it calls exit.
>
> We understand that killing the host program is not very polite,
> but what else
> could it do when facing a real bad error? It cannot return to the
> application
> because the state might be unusable after a memory allocation error.
>
> Just to make it clear: Lua only calls exit when some error
> happens *outside*
> the execution of a chunk. It does not need to be a bad error at
> all. It might
> simply be lua_error called directly from C at the top level (that
> is, without
> going through Lua). It might be trying to index an undefined variable or
> something like this.
>
> One simple way to avoid exits is to make sure that Lua is always
> called inside
> an execution context, and this is simple to do by running your code as an
> ordinary Lua function. In other words, in main do whatever initialization
> is needed, including opening Lua, and then call a function to do
> the actual
> work using lua_pushcfunction and lua_call(L,0,0).
> --lhf
>