[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Calling back into lua from a gc method -- okay?
- From: "Adam D. Moss" <adam@...>
- Date: Thu, 12 Dec 2002 21:52:32 +0000
Hello!
I've been spending a few hours trying to track down a crasher
in my code which consistantly occurs at the following
place (in lua 5.0a):
Program received signal SIGSEGV, Segmentation fault.
0x0807521f in luaV_execute (L=0x812c850) at lvm.c:385
385 k = cl->p->k;
(gdb) print cl
$1 = (struct LClosure *) 0x0
Whenever I (rarely) see a crash in lua itself, the first thing I
check is whether I'm under/overflowing the virtual stack, which is
usually the case, then I go looking for memory-stomping thinkos with
the help of valgrind, and only as a last resort do I even begin to
consider blaming lua. :)
In the absence of known bugs in lua 5.0a itself which might be to
blame, I've thought of one naughty thing which I'm doing which I
think might be confusing lua, but I'm not sure. The documentation
doesn't forbid it.
This naughty (but rather useful) thing is that I'm calling back into
lua from a cfunction being called as a heavy userdata's __gc method.
Is this supposed to be okay? I can see why it might be a problem if
this hasn't been designed for.
Anyway, here's the full backtrace -- the crash doesn't (as
far as I can tell) actually happen during the suspicious GC,
but shortly afterwards. Browsing the function parameters
in the debugger down the various stack frames doesn't show any
obvious 'bad' values being passed around.
Program received signal SIGSEGV, Segmentation fault.
0x0807521f in luaV_execute (L=0x812c850) at lvm.c:385
385 k = cl->p->k;
(gdb) bt
#0 0x0807521f in luaV_execute (L=0x812c850) at lvm.c:385
#1 0x0806fa07 in luaD_call (L=0x812c850, func=0x818193c, nResults=0) at
ldo.c:291
#2 0x0806fcca in f_call (L=0x812c850, ud=0xbffff320) at ldo.c:386
#3 0x0806f09a in luaD_rawrunprotected (L=0x812c850, f=0x806fca8
<f_call>, ud=0xbffff320) at ldo.c:84
#4 0x0806fd42 in luaD_pcall (L=0x812c850, nargs=3, nresults=0,
errfunc=24) at ldo.c:400
#5 0x0806d9ce in lua_pcall (L=0x812c850, nargs=3, nresults=0,
errfunc=-5) at lapi.c:634
#6 0x0806a300 in zlua_pcall (state=0x812c850, nargs=3, nresults=0) at
zlua.c:21
#7 0x0806a454 in zeitscript_event_dispatch (eventname=0x808fa23 "FrEn",
eventdata=0x80e2040, listener_data=0x812e3fc)
at api_util.c:122
#8 0x08063f9b in send_event_to_listener (listener=0x812e3fc,
eventname=0x808fa23 "FrEn", eventdata=0x80e2040)
at triggers.c:216
#9 0x08063b81 in triggerEvent (trigger=0x812bc48, eventname=0x808fa23
"FrEn", eventdata=0x80e2040) at triggers.c:244
#10 0x0804bdc2 in game_main_loop () at main.c:408
#11 0x0804baba in main (in_argc=0, in_argv=0x0) at main.c:472
#12 0x4014e1f6 in __libc_start_main () from /lib/libc.so.6
(gdb) print cl
$1 = (struct LClosure *) 0x0
Thanks for any insights,
--Adam
--
Adam D. Moss . ,,^^ adam@gimp.org http://www.foxbox.org/ co:3