lua-users home
lua-l archive

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

The code:
        lua_rawgeti(L, LUA_ENVIRONINDEX, arg->callbackRef);
        lua_pushinteger(L, event);
        ret = lua_resume(L, 1);
pushes two things on the stack belonging to L, and then resumes
that thread claiming to provide one argument. That's only valid
if the thread is "fresh" and the first thing you're pushing is
a closure. When the closure return's (rather than yielding), the
thread is once again "fresh" and there is no active closure;
consequently, the use of LUA_ENVIRONINDEX is invalid and will
lead to a crash.
Sorry, the callbackRef item is misleading... it actually refers to the
thread to resume...
I suppose to resume a thread that yielded I would have to use it's L
pointer (strange enough though it works...)...

I just realized that the lua_States that I'm passing around in the
callback state actually refer to the coroutine that I want to resume.
I think doing this may fix the issue (since oftentimes when things go
bad in Lua things go bad elsewhere and mask the real issue).

I tried out the ldb's patch and set up the debugging and sometimes it
segfaults w/o any message.. though that's probably because of some
special error case that isn't caught.
Thomas Harning Jr.