lua-users home
lua-l archive

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


I decided to move to using callbacks and having Lua code do coroutine
management... more flexible anyways.  It also helps manage the
lifetime of the coroutine, since I need to keep it in something to
prevent its collection.  I ran into some interesting issues where Lua
had freed the coroutine and it still ran, but segfaulted later on.
Valgrind was a great tool there...

Now that I have this callback system in place, I'm running into new
issues... it seems that the instruction pointer is getting messed up
and/or strange stack curruption issues.

I've attached a tarball of the code.  Note that I'm using libevent-1.3b...
Hopefully the problems can be fixed easily... perhaps the library
could also get 'shrunk'... though for what it does, it's pretty good.

With the ldb-patched code + API assertions:
TRACE >: 	addserver
TRACE >: 	create
TRACE >: 	coro
TRACE >: 	setupHook
TRACE >: 	sethook
TRACE >: 	resume
TRACE 	thread: 0x52e280	>: 	nil
TRACE 	thread: 0x52e280	>: 	getWrapper
TRACE 	thread: 0x52e280	>: 	running
TRACE 	thread: 0x52e280	>: 	addevent
TRACE 	thread: 0x52e280	>: 	nil
TRACE 	thread: 0x52e280	>: 	yield
TRACE >: 	assert
TRACE >: 	loop
TRACE 	thread: 0x52e280	>: 	nil
TRACE 	thread: 0x52e280	>: 	resume
TRACE 	thread: 0x52e280	>: 	select
lua: lapi.c:502: lua_pushboolean: Assertion `(L->top <= L->ci->top) ||
luaAC_report(L, "Stack overflow -- see lua_checkstack")' failed.


Without the API assertions...
TRACE >: 	addserver
TRACE >: 	create
TRACE >: 	coro
TRACE >: 	setupHook
TRACE >: 	sethook
TRACE >: 	resume
TRACE 	thread: 0x526980	>: 	nil
TRACE 	thread: 0x526980	>: 	getWrapper
TRACE 	thread: 0x526980	>: 	running
TRACE 	thread: 0x526980	>: 	addevent
TRACE 	thread: 0x526980	>: 	nil
TRACE 	thread: 0x526980	>: 	yield
TRACE >: 	assert
TRACE >: 	loop
TRACE 	thread: 0x526980	>: 	nil
TRACE 	thread: 0x526980	>: 	resume
TRACE 	thread: 0x526980	>: 	select
TRACE 	thread: 0x526980	>: 	nil
TRACE 	thread: 0x526980	>: 	print
TRACE 	thread: 0x526980	>: 	nil
userdata: 0x512648
TRACE 	thread: 0x526980	>: 	receive
PANIC: unprotected error in call to Lua API (./luaevent.lua:39:
attempt to index local 'sock' (a userdata value))



--
Thomas Harning Jr.