在 2016/1/9 20:35, 张伟智 写道:
Lua version is 5.2.4.
In lgc.c line 820, function GCTM,
g->gcrunning is set to 0 to avoid GC steps,
I think if g->gcrunning remains unchanged,
line 824 luaD_pcall will trigger luaC_step->luaC_forcestep->GCTM
during executing __gc finalizer.
But what is the problem if recursive enter GCTM ?
In my understanding, the Lua VM is reentrant, but the finalizers are
meant to be called
in sequence. according to Lua's semantic, the finalizers are called in
the reverse order
that the objects were marked for for finalization. so the finalizer
for the next object
must be called _after_ the current object's finished its execution.