close_state
function · lua · boundary
- Address
0x6f6ef0· 142 bytes, up to0x6f6f7d- Meaning
- Closes upvalues, sweeps every object, and frees the string table, the stacks and the global state
- Confidence
- verified, proof one
- Finding
- lua/runtime#state-open-and-close
Finding: State open and close in lua: calls, states and the collector
lua_open (ui/luastate) runs f_luaopen in protected mode. It allocates the 192-byte global
state and stores default_panic in it, calls stack_init (a stack of 45 slots and 8 call
records), makes the default metatable (its own metatable), the globals table and the registry,
sizes the string table at 32, runs luaT_init and luaX_init, fixes the not enough memory
string and sets the first threshold to four times the block count. luaE_newthread makes a
coroutine state. close_state closes the upvalues, sweeps every object, frees the stacks, calls the
client's memory-pool teardown 0x6fb2f0 (0x6f6f54) and frees the global state. mallocstate, freestate, freestack and luaE_freethread allocate and free the
records, and callallgcTM is the protected function that runs the last finalizers.
| function | name | decided by |
|---|---|---|
0x6f6b10 | luaE_newthread | mallocstate (0x6f6b14), luaC_link type 8 (0x6f6b21), preinit_state (0x6f6b28), stack_init (0x6f6b37) |
0x6f6b80 | mallocstate | luaM_irealloc in lstate.c for 0x68 bytes (0x6f6b8d) |
0x6f6ba0 | stack_init | two luaM_irealloc in lstate.c for 0x2d0 and 0xc0 bytes (0x6f6bb8, 0x6f6be4) |
0x6f6c90 | luaE_freethread | luaF_close (0x6f6c9b), freestack (0x6f6ca4), tail jmp to freestate (0x6f6caf) |
0x6f6cc0 | freestate | luaM_irealloc in lstate.c (0x6f6ccb) |
0x6f6ce0 | freestack | two luaM_irealloc in lstate.c (0x6f6cfd, 0x6f6d17) |
0x6f6d70 | f_luaopen | allocates 0xc0 bytes (0x6f6d88), panic store (0x6f6ddd), three luaH_new (0x6f6e3b, 0x6f6e62, 0x6f6e87), luaS_resize 32 (0x6f6e96), luaT_init (0x6f6e9d), threshold shl 2 (0x6f6ec8) |
0x6f6ee0 | default_panic | three bytes: xor eax,eax; ret |
0x6f6ef0 | close_state | luaF_close (0x6f6ef6), luaC_sweep (0x6f6f09), luaS_freeall (0x6f6f10), freestack (0x6f6f46), pool teardown 0x6fb2f0 (0x6f6f54), freestate (0x6f6f79) |
0x6f6fe0 | callallgcTM | tail jmp to luaC_callGCTM (0x6f6fe0) |
0x6f7b40 | luaT_init | loop over the name table (0x6f7b72), luaS_newlstr, limit 0xbc (0x6f7b8c), the fixed bit 0x10 |
The derivation is in the doc.
Callers 2
Callees 7
- freestate lua
- freestack lua
- luaC_sweep lua
- luaS_freeall lua
- luaF_close lua
- FreeBlockPools lua
- luaM_irealloc lua
Calls and jumps by a bare address, from tables/calls.tsv.