[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: luajit can't use lua_error and longjmp at same time?
- From: Siddon Tang <siddontang@...>
- Date: Mon, 21 Feb 2011 10:56:27 +0800
2011/2/19 Mike Pall <firstname.lastname@example.org>
Siddon Tang wrote:
> longjmp(buffer, 1);
C++ exceptions and longjmp do not mix well on most platforms.
LuaJIT directly throws a low-level exception on x64. The catch()
> If I use lua_error to throw a exception, the program will abort when second
> call DoFunc.
opens a C++ exception handling context. But since you longjmp out
of it, it never gets closed. That's why it crashes next time.
It looks like C++ throw has special handling to avoid this and
> But when I use throw instead, all works fine.
resets the context. Alas, I can't do this with the low-level
exceptions used by LuaJIT (and I can't use C++ throw either).
The problem is not mixing Lua errors and C++ exceptions. This
> In the luajit extensions, it said "Throwing Lua errors across C++ frames is
> safe", maybe can't be used with longjmp at same time?
works fine on x64, because they use the same underlying mechanism.
But mixing longjmp with C++ exceptions is generally not
recommended. As we can see, there's a good reason for it.
Well, Thank you very much!
I think I will not mix longjmp and c++ exception together.