Just to make sure I got it: if lua code calls into C++ and lua_error needs to be raised from C++, no try-catch allowed between the lua code and the function which issue the lua_error, inclusive. And also automatically destroyed objects will not be destroyed there? Thanks again, Uri On Wed, May 23, 2012 at 10:34 PM, Mike Pall <mike-1205@xxxxxxxxxx> wrote: > Uri Cohen wrote: > > I'm running luajit on x86 and hit the issue of interoperability for C++ > > Exceptions mentioned in the documentation< > http://luajit.org/extensions.html> > > . > > I didn't quite followed what's the recommended way to handle lua_error in > > C++... > > > > Specifically, I have c++ (1) calling into lua calling back into c++ (2). > An > > exception is thrown deep in (2), and as I don't want to pass it into lua > I > > catch it in c++ (2) and raise lua_error. This messes up the SEH and > causes > > access violation when handling the lua_error at c++ (1), when the code > > there tries to raise an exception about the error. What's the recommended > > solution there? > > Somebody got my suggested workaround to run: > > http://lua-users.org/lists/lua-l/2010-10/msg00521.html > > But please note: the _calling_ function must run lua_error, the > _called_ function must use try/catch and communicate it back, e.g. > through the return value. No functions in the stack up to the > calling functions may use try/catch or finalizers. > > Yes, I know, this is a rather annoying workaround. But the SEH > patent stops me from doing anything about that. > > --Mike > > -- Uri Cohen