Re: Catching 'out of memory' using pcall()

  • From: Mike Pall <mike-1403@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Mon, 17 Mar 2014 20:13:24 +0100

Dmitri Shubin wrote:
> How can we unwind stack to some safe state and free memory occupied
> by this particular lua state?
> Can we throw C++ exception, do longjmp() or ?

LuaJIT already uses the native exception mechanism (i.e. C++
exceptions) to do the unwinding on x64. But that crashes if
there's an intervening JIT-compiled frame.

Longjmp might work, but then the LuaJIT VM is no longer in a sane
state. The only option would be to print some error and exit the
process (without touching the VM anymore).

--Mike

Other related posts: