mirror of
https://github.com/lua/lua.git
synced 2026-06-08 08:03:49 +00:00
More effort in avoiding errors in finalizers
Before calling a finalizer, Lua not only checks stack limits, but actually ensures that a minimum number of slots are already allocated for the call. (If it cannot ensure that, it postpones the finalizer.) That avoids finalizers not running due to memory errors that the programmer cannot control.
This commit is contained in:
2
lgc.c
2
lgc.c
@@ -1293,7 +1293,7 @@ static void finishgencycle (lua_State *L, global_State *g) {
|
||||
correctgraylists(g);
|
||||
checkSizes(L, g);
|
||||
g->gcstate = GCSpropagate; /* skip restart */
|
||||
if (!g->gcemergency && luaD_checkminstack(L))
|
||||
if (g->tobefnz != NULL && !g->gcemergency && luaD_checkminstack(L))
|
||||
callallpendingfinalizers(L);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user