lua-users home
lua-l archive

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


On May 09, 2003 at 08:55 -0700, Bilyk, Alex wrote:
> The following script crashes lua.exe under Win2K/VC.NET. 
> 
> -----------------------------------------------
> function co_func (current_co)
>    coroutine.resume(current_co)
> end
> 
> local co = coroutine.create(co_func)
> coroutine.resume(co, co)
> -----------------------------------------------

The above script runs OK on my machine, Linux 2.4.20-386, Debian
testing.  However, if I repeat the last line, I get a seg fault!

Here's some info from gdb.  I didn't really try to track down the bug
though.

---- 
Program received signal SIGSEGV, Segmentation fault.
0x4005d598 in lua_xmove (from=0x804c530, to=0x8050b08, n=1)
    at /home/tulrich/src/luacheia/lua-5.0/src/lapi.c:121
121     setobj2s(to->top, from->top + i);
(gdb) bt
#0  0x4005d598 in lua_xmove (from=0x804c530, to=0x8050b08, n=1)
    at /home/tulrich/src/luacheia/lua-5.0/src/lapi.c:121
#1  0x40050f34 in auxresume (L=0x804c530, co=0x8050b08, narg=1)
    at /home/tulrich/src/luacheia/lua-5.0/src/lib/lbaselib.c:547
#2  0x40051002 in luaB_coresume (L=0x804c530)
    at /home/tulrich/src/luacheia/lua-5.0/src/lib/lbaselib.c:567
#3  0x40061a24 in luaD_precall (L=0x804c530, func=0x8053158)
    at /home/tulrich/src/luacheia/lua-5.0/src/ldo.c:260
#4  0x4006b7cc in luaV_execute (L=0x804c530)
    at /home/tulrich/src/luacheia/lua-5.0/src/lvm.c:625
#5  0x40061bc2 in luaD_call (L=0x804c530, func=0x8053140, nResults=-1)
    at /home/tulrich/src/luacheia/lua-5.0/src/ldo.c:313
#6  0x4005e3c7 in lua_call (L=0x804c530, nargs=0, nresults=-1)
    at /home/tulrich/src/luacheia/lua-5.0/src/lapi.c:655
#7  0x4005065d in luaB_dofile (L=0x804c530)
    at /home/tulrich/src/luacheia/lua-5.0/src/lib/lbaselib.c:279
#8  0x40061a24 in luaD_precall (L=0x804c530, func=0x8053128)
    at /home/tulrich/src/luacheia/lua-5.0/src/ldo.c:260
#9  0x4006b7cc in luaV_execute (L=0x804c530)
    at /home/tulrich/src/luacheia/lua-5.0/src/lvm.c:625
#10 0x40061bc2 in luaD_call (L=0x804c530, func=0x805311c, nResults=-1)
    at /home/tulrich/src/luacheia/lua-5.0/src/ldo.c:313
#11 0x4005e3f2 in f_call (L=0x804c530, ud=0xbffff720)


(gdb) l
116     int i;
117	lua_lock(to);
118	api_checknelems(from, n);
119	from->top -= n;
120	for (i = 0; i < n; i++) {
121	  setobj2s(to->top, from->top + i);
122	  api_incr_top(to);
123	}
124	lua_unlock(to);
125   }
(gdb) print to
$1 = (lua_State *) 0x8050b08
(gdb) print from
$2 = (lua_State *) 0x804c530
(gdb) print i
$3 = 1
(gdb) print *(to->top)
Cannot access memory at address 0x2a2ad3b4
(gdb) print *(from->top)
$6 = {tt = 8, value = {gc = 0x8050b08, p = 0x8050b08, 
    n = 6.6475659139877875e-316, b = 134548232}}

-- 
Thatcher Ulrich
http://tulrich.com