diff options
| author | Roberto I <roberto@inf.puc-rio.br> | 2026-07-22 14:42:55 -0300 |
|---|---|---|
| committer | Roberto I <roberto@inf.puc-rio.br> | 2026-07-22 14:42:55 -0300 |
| commit | 8511e90b7df5daf139aba290b9c9c1595927e7b3 (patch) | |
| tree | c785e4595f212d9972fe9f40d2bb58a980a9257b /lstate.c | |
| parent | 0f781f836ab348716eb9232d3831a871b9821a3c (diff) | |
| download | lua-8511e90b7df5daf139aba290b9c9c1595927e7b3.tar.gz lua-8511e90b7df5daf139aba290b9c9c1595927e7b3.tar.bz2 lua-8511e90b7df5daf139aba290b9c9c1595927e7b3.zip | |
Bug: GC checks stack space before running finalizer
If some stack does not have a minimum available space, the GC defers
calling a finalizer until the next cycle. That avoids errors while
running a finalizer that the programmer cannot control.
Diffstat (limited to 'lstate.c')
| -rw-r--r-- | lstate.c | 17 |
1 files changed, 11 insertions, 6 deletions
| @@ -102,14 +102,19 @@ LUA_API int lua_setcstacklimit (lua_State *L, unsigned int limit) { | |||
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | 104 | ||
| 105 | CallInfo *luaE_extendCI (lua_State *L) { | 105 | CallInfo *luaE_extendCI (lua_State *L, int err) { |
| 106 | CallInfo *ci; | 106 | CallInfo *ci; |
| 107 | lua_assert(L->ci->next == NULL); | 107 | ci = luaM_reallocvector(L, NULL, 0, 1, CallInfo); |
| 108 | ci = luaM_new(L, CallInfo); | 108 | if (l_unlikely(ci == NULL)) { /* allocation failed? */ |
| 109 | lua_assert(L->ci->next == NULL); | 109 | if (err) |
| 110 | L->ci->next = ci; | 110 | luaM_error(L); /* raise the error */ |
| 111 | return NULL; /* else only report it */ | ||
| 112 | } | ||
| 113 | ci->next = L->ci->next; | ||
| 111 | ci->previous = L->ci; | 114 | ci->previous = L->ci; |
| 112 | ci->next = NULL; | 115 | L->ci->next = ci; |
| 116 | if (ci->next) | ||
| 117 | ci->next->previous = ci; | ||
| 113 | ci->u.l.trap = 0; | 118 | ci->u.l.trap = 0; |
| 114 | L->nci++; | 119 | L->nci++; |
| 115 | return ci; | 120 | return ci; |
