From ab834de8b6a963a83046a72b5a7751dcd6cdcff0 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Wed, 11 Feb 2026 23:12:53 +0100 Subject: Avoid recording interference due to invocation of VM hooks. Thanks to Sergey Kaplun. #1429 #1434 --- src/lj_dispatch.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/lj_dispatch.c') diff --git a/src/lj_dispatch.c b/src/lj_dispatch.c index 1e55c48a..636fb033 100644 --- a/src/lj_dispatch.c +++ b/src/lj_dispatch.c @@ -523,16 +523,18 @@ out: /* Stitch a new trace. */ void LJ_FASTCALL lj_dispatch_stitch(jit_State *J, const BCIns *pc) { - ERRNO_SAVE - lua_State *L = J->L; - void *cf = cframe_raw(L->cframe); - const BCIns *oldpc = cframe_pc(cf); - setcframe_pc(cf, pc); - /* Before dispatch, have to bias PC by 1. */ - L->top = L->base + cur_topslot(curr_proto(L), pc+1, cframe_multres_n(cf)); - lj_trace_stitch(J, pc-1); /* Point to the CALL instruction. */ - setcframe_pc(cf, oldpc); - ERRNO_RESTORE + if (!(J2G(J)->hookmask & HOOK_VMEVENT)) { + ERRNO_SAVE + lua_State *L = J->L; + void *cf = cframe_raw(L->cframe); + const BCIns *oldpc = cframe_pc(cf); + setcframe_pc(cf, pc); + /* Before dispatch, have to bias PC by 1. */ + L->top = L->base + cur_topslot(curr_proto(L), pc+1, cframe_multres_n(cf)); + lj_trace_stitch(J, pc-1); /* Point to the CALL instruction. */ + setcframe_pc(cf, oldpc); + ERRNO_RESTORE + } } #endif -- cgit v1.2.3-55-g6feb