lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Arseny Vakhrushev wrote:
> I've been playing around for a while to get my project linked
> with LuaJIT for testings. The library compliled without any
> problems, and I needed to make some minor changes to my source
> code to get rid of some vanilla Lua dependencies (I used
> lua_number2integer macro two times in the code). However, the
> first time I ran it, it crashed with segfault. Valgrind said
> about some unconditional jumps instead of that which may happen
> of course.

Seeing the Valgrind messages might be helpful. But recompile
LuaJIT first with -DLUAJIT_USE_VALGRIND and -DLUA_USE_ASSERT
(see src/Makefile).

> I tried to get into the LuaJIT code to figure out
> what was going on, but it's not so easy from the first sight.
> The crash is somehow connected with a run-time error in Lua (I'm
> calling a non-existent function from a table, not global). The
> Lua code looks as the following:
> 
> ------------------------------------------------------------------------------
> cnt = 0
> a() -- <<<<< SEGFAULT HERE!!!!

Well, this example doesn't crash here with the LuaJIT standalone
executable. So you must be doing something else in your embedding.
Very likely you are catching the error with lua_pcall() or
lua_resume() and then doing some processing on it.

> I'm posting it as is (never mind non-standard calls and libs!)
> because when I remove arbitrary lines, the error goes away.

What happens if you run it with jit.off()?

> 814       lj_err_throw(L, LUA_ERRRUN);
> (gdb) n
> 
> Breakpoint 4, currentline (L=0x40003c70, fn=0x400021d0, nextframe=0x40008388) at lj_err.c:136
> 136         return proto_line(pt, pc);

There is no direct code path from one function to the other. So
something in your application is invoking some debug functionality
(probably debug.traceback() or lua_getinfo()) as a reaction to
catching the error. I'd need to see a C stack traceback at the
point before the crash ('bt') plus the contents of pt and pc.

Since this is probably not of general interest for the mailing
list, I suggest to mail it directly to me.

BTW: Your posting is in HTML-only format, but goes to a mailing
list which is primarily text-only. Please consider reconfiguring
your gmail account to send text-only format messages. Thank you!

--Mike