[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lua_pushstring, luaC_checkGC and top changing (grows by 2)
- From: Felipe Magno de Almeida <felipe.m.almeida@...>
- Date: Mon, 25 Jan 2010 19:13:20 -0200
On Mon, Jan 25, 2010 at 6:41 PM, Felipe Magno de Almeida
> I'm seeing that when GCTM is called after a luaC_checkGC where the
> threshold is hit, the lua_gettop(L) grows by 2.
> This happens within GCTM where lua_gettop(L) == 0 and L->top is added by 2.
> Then the luaD_call doesn't consume the two from L->top.
> This only happens when the first GCTM is called.
> All this happens while Lua is in a infinite loop.
> A hook count is set every 2 instructions, and yields.
> Everything is ran through a loop with lua_resume which every LUA_YIELD
> it gets from a table indexed by a string.
> Everything uses luabind in C++, and I can't really show the code that
> happens this exactly.
> But it is very obvious from running the debugger that after calling
> lua_pushstring the lua_gettop(L) goes from 0 to 3, and this happens
> because luaC_checkGC returns with lua_gettop(L) == 2 and then
> lua_pushlstring increments the top after setting the string in the
> This happens exactly after indexing the table 63 times. IOW, on the
> 64th iteration.
Though I'm not knowledgeable enough in lua's internals.
It seems ci->base is never updated with current base before calling
the Cfunction. Only savedpc is.
And this value is used to set L->base back in poscall.
I've added in line 272 in ldo.c the following code:
L->ci->base = L->base;
And until now it worked here.
> Any help would be appreciated,
> Thanks in advance,
> Felipe Magno de Almeida
Felipe Magno de Almeida