When you interact with Lua API, you are responsible for controlling stack overflow. The
function
int lua_checkstack (lua_State *L, int extra);
grows the stack size to top + extra elements; it returns false if it cannot grow the stack to that
size. This function never shrinks the stack; if the stack is already larger than the new size, it is left
unchanged.
拆分script以后
有时候会断在lua_close上~
具体位置如下:
LUA_API void lua_close (lua_State *L) {
lua_lock(L);
L = G(L)->mainthread; /* only the main thread can be closed */
luaF_close(L, L->stack); /* close all upvalues for this thread */
luaC_separateudata(L); /* separate udata that have GC metamethods */
L->errfunc = 0; /* no error function during GC metamethods */
do { /* repeat until no more errors */
L->ci = L->base_ci;
L->base = L->top = L->ci->base;
L->nCcalls = 0;
} while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0); //断在这里
lua_assert(G(L)->tmudata == NULL);
close_state(L);
}