Hi,
I am encountering segfault in my application embedding luajit2. Here is how C stack trace looks like at segfault moment:
> lj_debug_funcname(lua_State * L=0x0000000002140a88, const TValue * frame=0x00000000004c0378, const char * * name=0x0000000140a0fa78) Line 305 + 0x10 bytes C
lj_debug_getinfo(lua_State * L=0x00000000004c0378, const char * what=0x0000000000000000, lj_Debug * ar=0x0000000002218080, int ext=0) Line 485 + 0x14 bytes C
luaL_traceback(lua_State * L=0x00000000004c0378, lua_State * L1=0x0000000002140a88, const char * msg=0x00000000025f2e28, int level=4981624) Line 677 C
lj_cf_debug_traceback(lua_State * L=0x00000000004c0f98) Line 394 C
lj_BC_FUNCC() + 0x32 bytes
lua_pcall(lua_State * L=0x0000000000000000, int nargs=8, int nresults=0, int errfunc=0) Line 1042 C
docall(lua_State * L=0x00000000004c0378, int narg=0, int clear=-1) Line 124 C
handle_script(lua_State * L=0x00000000004c0378, char * * argv=0x00000000004c0378, int n=0) Line 289 + 0x11 bytes C
pmain(lua_State * L=0x0000000000000000) Line 544 + 0xe bytes C
lj_BC_FUNCC() + 0x32 bytes
lua_cpcall(lua_State * L=0x00000000004c0378, int (lua_State *)* func=0x00000000022288e0, void * ud=0x00000001409fe3d0) Line 1064 C
I need to determine the Lua stack trace. I am using this function for that purpose:
void __lua_stacktrace__(lua_State* L)
{
lua_Debug entry;
int depth = 0;
while (lua_getstack(L, depth, &entry))
{
int status = lua_getinfo(L, "nSlu", &entry);
//assert(status);
printf("[%d] %s(%d): %s\n", depth, entry.short_src, entry.currentline, entry.name ? entry.name : "?");
++depth;
}
printf("print complete\n");
}
But something goes wrong when executing __lua_stacktrace__(L);
Access violation reading location 0x0000000000000010.
Is it possible that lua_State * is not in consistent state?
What tools or code can I use to find Lua stack trace at time of the crash ?
Is there a place where I can insert code to save current Lua stack trace on every Lua instruction ? so that I cal look at saved stack trace(last stack trace) even when lua_State * is inconsistent.
Thanks,
Alex