diff options
| author | Roberto I <roberto@inf.puc-rio.br> | 2025-12-13 16:16:59 -0300 |
|---|---|---|
| committer | Roberto I <roberto@inf.puc-rio.br> | 2025-12-13 16:16:59 -0300 |
| commit | a5522f06d2679b8f18534fd6a9968f7eb539dc31 (patch) | |
| tree | 65275619e7829b569bfb18dea624358aa17dbc91 /ldo.c | |
| parent | 3d03ae5bd6314f27c8635e06ec363150c2c19062 (diff) | |
| download | lua-a5522f06d2679b8f18534fd6a9968f7eb539dc31.tar.gz lua-a5522f06d2679b8f18534fd6a9968f7eb539dc31.tar.bz2 lua-a5522f06d2679b8f18534fd6a9968f7eb539dc31.zip | |
If the stack does not have some 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 'ldo.c')
| -rw-r--r-- | ldo.c | 11 |
1 files changed, 11 insertions, 0 deletions
| @@ -221,6 +221,17 @@ l_noret luaD_errerr (lua_State *L) { | |||
| 221 | 221 | ||
| 222 | 222 | ||
| 223 | /* | 223 | /* |
| 224 | ** Check whether stack has enough space to run a simple function (such | ||
| 225 | ** as a finalizer): At least BASIC_STACK_SIZE in the Lua stack and | ||
| 226 | ** 2 slots in the C stack. | ||
| 227 | */ | ||
| 228 | int luaD_checkminstack (lua_State *L) { | ||
| 229 | return ((stacksize(L) < MAXSTACK - BASIC_STACK_SIZE) && | ||
| 230 | (getCcalls(L) < LUAI_MAXCCALLS - 2)); | ||
| 231 | } | ||
| 232 | |||
| 233 | |||
| 234 | /* | ||
| 224 | ** In ISO C, any pointer use after the pointer has been deallocated is | 235 | ** In ISO C, any pointer use after the pointer has been deallocated is |
| 225 | ** undefined behavior. So, before a stack reallocation, all pointers | 236 | ** undefined behavior. So, before a stack reallocation, all pointers |
| 226 | ** should be changed to offsets, and after the reallocation they should | 237 | ** should be changed to offsets, and after the reallocation they should |
