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

  • From: Dmitri Shubin <sbn@xxxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Mon, 17 Mar 2014 14:29:06 +0400

On 03/13/2014 01:47 PM, Mike Pall wrote:
Dmitri Shubin wrote:
$ ./src/luajit a.lua
PANIC: unprotected error in call to Lua API (not enough memory)
Documented at: http://luajit.org/status.html

Thanks for pointing this out!

Could it lead crash with the following backtrace:

#0 tbricks::transport::CRASH_HANDLER (signum=11) at src/Application.cpp:1005
#1  <signal handler called>
#2 0x00007fb10287ffac in err_unwind (L=0x7bbf9378, stopcf=0x7fb0e97f9500, errcode=0) at lj_err.c:113 #3 0x00007fb10287fbb7 in lj_err_unwind_dwarf (version=1, actions=1, uexclass=5500374307216568836, uex=0x7fb0e97fc5e0, ctx=0x7fb0e97f90c0) at lj_err.c:247 #4 0x00007fb0ff864686 in _Unwind_RaiseException () from /lib64/libgcc_s.so.1
#5  0x00007fb10288049a in err_raise_ext (errcode=4) at lj_err.c:308
#6 0x00007fb102880400 in lj_err_throw (L=0x7bbf9378, errcode=4) at lj_err.c:462
#7  0x00007fb1028805f4 in lj_err_mem (L=0x7bbf9378) at lj_err.c:498
#8 0x00007fb10287d831 in lj_mem_newgco (L=0x7bbf9378, size=32) at lj_gc.c:818 #9 0x00007fb102883cb8 in newtab (L=0x7bbf9378, asize=0, hbits=1) at lj_tab.c:112 #10 0x00007fb10288404a in lj_tab_dup (L=0x7bbf9378, kt=0x7bc10cb8) at lj_tab.c:167 #11 0x00007fb10287847a in lj_BC_TDUP () from /home/sbn/tb/tb/build.x86_64-unknown-linux/bin/../platform/lib64/libluajit-5.1.so.2 #12 0x00007fb10289c195 in lua_pcall (L=0x7bbf9378, nargs=2, nresults=0, errfunc=0) at lj_api.c:1055
<application-specific frames omitted>

In lj_err.c:

   110      switch (frame_typep(frame)) {
   111      case FRAME_LUA:  /* Lua frame. */
   112      case FRAME_LUAP:
   113        frame = frame_prevl(frame);
   114        break;

I.e. looks like broken lua stack.

Other related posts: