Skip to content

Commit ff1e72a

Browse files
author
Mike Pall
committed
LJ_GC64: Always snapshot functions for non-base frames.
Reported by Arseny Vakhrushev. Analysis and fix contributed by Peter Cawley.
1 parent 94d4abc commit ff1e72a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/lj_record.c

+1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ static TRef getcurrf(jit_State *J)
211211
{
212212
if (J->base[-1-LJ_FR2])
213213
return J->base[-1-LJ_FR2];
214+
/* Non-base frame functions ought to be loaded already. */
214215
lj_assertJ(J->baseslot == 1+LJ_FR2, "bad baseslot");
215216
return sloadt(J, -1-LJ_FR2, IRT_FUNC, IRSLOAD_READONLY);
216217
}

src/lj_snap.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,13 @@ static MSize snapshot_slots(jit_State *J, SnapEntry *map, BCReg nslots)
8585
IRIns *ir = &J->cur.ir[ref];
8686
if ((LJ_FR2 || !(sn & (SNAP_CONT|SNAP_FRAME))) &&
8787
ir->o == IR_SLOAD && ir->op1 == s && ref > retf) {
88-
/* No need to snapshot unmodified non-inherited slots. */
89-
if (!(ir->op2 & IRSLOAD_INHERIT))
88+
/*
89+
** No need to snapshot unmodified non-inherited slots.
90+
** But always snapshot the function below a frame in LJ_FR2 mode.
91+
*/
92+
if (!(ir->op2 & IRSLOAD_INHERIT) &&
93+
(!LJ_FR2 || s == 0 || s+1 == nslots ||
94+
!(J->slot[s+1] & (TREF_CONT|TREF_FRAME))))
9095
continue;
9196
/* No need to restore readonly slots and unmodified non-parent slots. */
9297
if (!(LJ_DUALNUM && (ir->op2 & IRSLOAD_CONVERT)) &&

0 commit comments

Comments
 (0)