[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua stack clean
- From: Sean Conner <sean@...>
- Date: Wed, 24 Feb 2021 20:53:46 -0500
It was thus said that the Great Ranier Vilela once stated:
> You mean don't have to call lua_pop?
It depends upon the code.
> I have a bug reading an invalid pointer, in an adjacent library, which I'm
> not sure is caused by Lua gc.
It may be an issue over who owns the memory for the userdata, but without
knowing the exact error, it's hard to say.
Here's a function (for Lua 5.2+) that I use to debug Lua stack issues:
static int cstack(lua_State *L)
int max = lua_gettop(L);
for (int i = 1 ; i <= max ; i++)
"%d %d - %s %s\n",
i - max - 1,
I wil add calls to this funciton at points where I want to know what's on
the stack, and at what index (this will print both positive and negative
-spc (Hope this helps)