summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2020-10-12 15:45:05 +0200
committerMike Pall <mike>2020-10-12 15:45:05 +0200
commit5c46f47736f7609be407c88d531ecd1689d40a79 (patch)
tree7358e4fedb6fdfd9080d96631c76e17a95906411
parentde6b1a11dd1a3349179084578c5d533be1c30234 (diff)
downloadluajit2-5c46f47736f7609be407c88d531ecd1689d40a79.tar.gz
Fix snapshot PC when linking to BC_JLOOP that was a BC_RET*.
Reported by Arseny Vakhrushev. Fix contributed by Peter Cawley.
-rw-r--r--src/lj_record.c9
-rw-r--r--src/lj_snap.c3
2 files changed, 8 insertions, 4 deletions
diff --git a/src/lj_record.c b/src/lj_record.c
index 69822f54..f5632f6c 100644
--- a/src/lj_record.c
+++ b/src/lj_record.c
@@ -513,10 +513,10 @@ static LoopEvent rec_iterl(jit_State *J, const BCIns iterins)
}
/* Record LOOP/JLOOP. Now, that was easy. */
-static LoopEvent rec_loop(jit_State *J, BCReg ra)
+static LoopEvent rec_loop(jit_State *J, BCReg ra, int skip)
{
if (ra < J->maxslot) J->maxslot = ra;
- J->pc++;
+ J->pc += skip;
return LOOPEV_ENTER;
}
@@ -2027,7 +2027,7 @@ void lj_record_ins(jit_State *J)
rec_loop_interp(J, pc, rec_iterl(J, *pc));
break;
case BC_LOOP:
- rec_loop_interp(J, pc, rec_loop(J, ra));
+ rec_loop_interp(J, pc, rec_loop(J, ra, 1));
break;
case BC_JFORL:
@@ -2037,7 +2037,8 @@ void lj_record_ins(jit_State *J)
rec_loop_jit(J, rc, rec_iterl(J, traceref(J, rc)->startins));
break;
case BC_JLOOP:
- rec_loop_jit(J, rc, rec_loop(J, ra));
+ rec_loop_jit(J, rc, rec_loop(J, ra,
+ !bc_isret(bc_op(traceref(J, rc)->startins))));
break;
case BC_IFORL:
diff --git a/src/lj_snap.c b/src/lj_snap.c
index de8068ac..bcd03038 100644
--- a/src/lj_snap.c
+++ b/src/lj_snap.c
@@ -97,6 +97,9 @@ static BCReg snapshot_framelinks(jit_State *J, SnapEntry *map)
cTValue *ftop = frame + funcproto(frame_func(frame))->framesize;
MSize f = 0;
map[f++] = SNAP_MKPC(J->pc); /* The current PC is always the first entry. */
+ lua_assert(!J->pt ||
+ (J->pc >= proto_bc(J->pt) &&
+ J->pc < proto_bc(J->pt) + J->pt->sizebc));
while (frame > lim) { /* Backwards traversal of all frames above base. */
if (frame_islua(frame)) {
map[f++] = SNAP_MKPC(frame_pc(frame));