Avoid recording interference due to invocation of VM hooks.

Thanks to Sergey Kaplun. #1429 #1434
This commit is contained in:
Mike Pall
2026-02-11 23:12:53 +01:00
parent eff4006837
commit ab834de8b6
2 changed files with 22 additions and 11 deletions

View File

@@ -523,6 +523,7 @@ out:
/* Stitch a new trace. */ /* Stitch a new trace. */
void LJ_FASTCALL lj_dispatch_stitch(jit_State *J, const BCIns *pc) void LJ_FASTCALL lj_dispatch_stitch(jit_State *J, const BCIns *pc)
{ {
if (!(J2G(J)->hookmask & HOOK_VMEVENT)) {
ERRNO_SAVE ERRNO_SAVE
lua_State *L = J->L; lua_State *L = J->L;
void *cf = cframe_raw(L->cframe); void *cf = cframe_raw(L->cframe);
@@ -534,6 +535,7 @@ void LJ_FASTCALL lj_dispatch_stitch(jit_State *J, const BCIns *pc)
setcframe_pc(cf, oldpc); setcframe_pc(cf, oldpc);
ERRNO_RESTORE ERRNO_RESTORE
} }
}
#endif #endif
#if LJ_HASPROFILE #if LJ_HASPROFILE

View File

@@ -467,7 +467,11 @@ static void trace_start(jit_State *J)
J->ktrace = 0; J->ktrace = 0;
setgcref(J->cur.startpt, obj2gco(J->pt)); setgcref(J->cur.startpt, obj2gco(J->pt));
lj_vmevent_send(J2G(J), TRACE, lj_vmevent_send_(J2G(J), TRACE,
TValue savetv = J2G(J)->tmptv;
TValue savetv2 = J2G(J)->tmptv2;
TraceNo parent = J->parent;
ExitNo exitno = J->exitno;
setstrV(V, V->top++, lj_str_newlit(V, "start")); setstrV(V, V->top++, lj_str_newlit(V, "start"));
setintV(V->top++, traceno); setintV(V->top++, traceno);
setfuncV(V, V->top++, J->fn); setfuncV(V, V->top++, J->fn);
@@ -482,6 +486,11 @@ static void trace_start(jit_State *J)
setintV(V->top++, -1); setintV(V->top++, -1);
} }
} }
,
J2G(J)->tmptv = savetv;
J2G(J)->tmptv2 = savetv2;
J->parent = parent;
J->exitno = exitno;
); );
lj_record_setup(J); lj_record_setup(J);
} }