[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: lua calling exit()
- From: "Bruno Silva" <brunocostasilva@...>
- Date: Mon, 20 Aug 2001 18:35:26 -0700
We use lua in a large project for certain ancillary purposes. In other
words, the execution of lua code is hardly critical to the main purpose
of the executable. But we have had many small problems with stack usage
in lua that turned into big problems (entire app exiting with no
warning). Just to make it 100% clear, all these problems were in the
host code, but I'd like to make it hard to code such mistakes, and
clearly identify them when it happens. So I have a couple of questions:
- What are some best practices for stack control?
- Do I have to extensively and manually check before every stack
operation to make sure I never pop an empty stack (causes protection
faults later on) or allow the stack to leak (eventually causes exit() on
the entire app)?
- Since beginblock/endblock are gone, are there other ways to easily
create stack sandboxes so that writing C/C++ bindings is easier and less
error prone with such drastic consequences?
- Is there a recommended way to completely prevent lua from ever calling
exit, or at least call my exit handler so I can let people know what's
going on? It seems it only gets called from luaD_breakrun, and only if
there isn't a setjmp context to return to. But we seem to be hitting
that on stack overflow, I think protected runs only happen for
interpreted code (not lua executed through C API calls).
- This is using Lua 4.0 and we override just _ERRORMESSAGE and print
Bruno