Fix interaction between profiler hooks and finalizers.

Thanks to Julien Desgats.
This commit is contained in:
Mike Pall
2019-12-08 19:56:56 +01:00
parent 9600e4318e
commit 92fa45f9eb
3 changed files with 5 additions and 2 deletions

View File

@@ -466,6 +466,7 @@ static void gc_call_finalizer(global_State *g, lua_State *L,
TValue *top;
lj_trace_abort(g);
hook_entergc(g); /* Disable hooks and new traces during __gc. */
if (LJ_HASPROFILE && (oldh & HOOK_PROFILE)) lj_dispatch_update(g);
g->gc.threshold = LJ_MAX_MEM; /* Prevent GC steps. */
top = L->top;
copyTV(L, top++, mo);
@@ -474,6 +475,7 @@ static void gc_call_finalizer(global_State *g, lua_State *L,
L->top = top+1;
errcode = lj_vm_pcall(L, top, 1+0, -1); /* Stack: |mo|o| -> | */
hook_restore(g, oldh);
if (LJ_HASPROFILE && (oldh & HOOK_PROFILE)) lj_dispatch_update(g);
g->gc.threshold = oldt; /* Restore GC threshold. */
if (errcode)
lj_err_throw(L, errcode); /* Propagate errors. */