lua-users home
lua-l archive

Re: Thread in library which call Lua function

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


On 15/04/2011 20:51, Roberto Ierusalimschy wrote:
I think i have a serious problem here, and i'm not waiting for you
for debugging my experiments. Which annoys me is that i was trying
to write a short program for isolating another problem i encounter
with re-entrance in Lua :(
So, i'm opened to all suggestions for solving the drifting problem.
Did you try compiling Lua with LUA_USE_APICHECK defined?
-- Roberto
No, i didn't knew this option.
I've built a Lua interpreter with this flag, and i get some more verbose errors now: lua_apicheck: lapi.c:432: lua_pushnumber: Assertion `L->top < L->ci->top' failed.
with
#define api_incr_top(L) {api_check(L, L->top < L->ci->top); L->top++;}
This time, it was in "lua_pushnumber", but i've also seen it in "lua_rawgeti". Sometimes, my program works for some time (two or three iterations in the thread, which call succesfully the lua callback function).
I know the problem is in my callback C function, in the DLL:
 lua_rawgeti (L_context, LUA_REGISTRYINDEX, index_fx_lua);
 lua_pcall(L_context, 0,0,0);
When i comment both two lines, it doesn't hang anymore.
When i comment the second line (lua_pcall), it still hang after three iterations, on this assert: lua_apicheck: lapi.c:573: lua_rawgeti: Assertion `L->top < L->ci->top' failed. For what i understand, it's something weird with the stack manipulation (good guess Sherlock, now time to go to bed).

AltStyle によって変換されたページ (->オリジナル) /