From 05f1984e1a862e4b3d3c3b370c773492e2edf84a Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Fri, 8 Oct 2021 16:50:35 +0200 Subject: [PATCH] Fix interaction of profiler and ITERN recording. Reported and analyzed by vfprintf. #754 --- src/lj_record.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lj_record.c b/src/lj_record.c index 4fe1a056..30722814 100644 --- a/src/lj_record.c +++ b/src/lj_record.c @@ -663,7 +663,9 @@ static LoopEvent rec_itern(jit_State *J, BCReg ra, BCReg rb) #else RecordIndex ix; /* Since ITERN is recorded at the start, we need our own loop detection. */ - if (J->pc == J->startpc && J->cur.nins > REF_FIRST && + if (J->pc == J->startpc && + (J->cur.nins > REF_FIRST+1 || + (J->cur.nins == REF_FIRST+1 && J->cur.ir[REF_FIRST].o != IR_PROF)) && J->framedepth + J->retdepth == 0 && J->parent == 0 && J->exitno == 0) { lj_record_stop(J, LJ_TRLINK_LOOP, J->cur.traceno); /* Looping trace. */ return LOOPEV_ENTER;