]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Different fix for partial snapshot restore due to stack overflow.
authorMike Pall <mike>
Wed, 14 Aug 2024 22:17:19 +0000 (00:17 +0200)
committerMike Pall <mike>
Wed, 14 Aug 2024 22:17:19 +0000 (00:17 +0200)
Reported by Junlong Li. Fixed by Peter Cawley. #1196

src/lj_snap.c
src/lj_trace.c

index 9858c1102e1b15eb23f663ec39c4e79017b6a42e..0c317b52d60e5b9ca8ec840a15b2027e8475298a 100644 (file)
@@ -873,7 +873,8 @@ const BCIns *lj_snap_restore(jit_State *J, void *exptr)
   lua_State *L = J->L;
 
   /* Set interpreter PC to the next PC to get correct error messages. */
-  setcframe_pc(cframe_raw(L->cframe), pc+1);
+  setcframe_pc(L->cframe, pc+1);
+  setcframe_pc(cframe_raw(cframe_prev(L->cframe)), pc);
 
   /* Make sure the stack is big enough for the slots from the snapshot. */
   if (LJ_UNLIKELY(L->base + snap->topslot >= tvref(L->maxstack))) {
index 8385f3d1e1845154273f2d1fb9cbcc271d4be9fd..d015f2ab9267140effecbb220755611eeb6145a7 100644 (file)
@@ -788,10 +788,8 @@ int LJ_FASTCALL lj_trace_exit(jit_State *J, void *exptr)
   exd.J = J;
   exd.exptr = exptr;
   errcode = lj_vm_cpcall(L, NULL, &exd, trace_exit_cp);
-  if (errcode) {
-    setcframe_pc(cframe_raw(L->cframe), L);  /* Point to any valid memory. */
+  if (errcode)
     return -errcode;  /* Return negated error code. */
-  }
 
   lj_vmevent_send(L, TEXIT,
     lj_state_checkstack(L, 4+RID_NUM_GPR+RID_NUM_FPR+LUA_MINSTACK);