]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Throw any errors before stack changes in trace stitching.
authorMike Pall <mike>
Mon, 14 Jun 2021 12:56:54 +0000 (14:56 +0200)
committerMike Pall <mike>
Mon, 14 Jun 2021 12:56:54 +0000 (14:56 +0200)
Thanks to doujiang24.

src/lj_ffrecord.c

index d050d12d752cdead4a5389b2ac39ad8f95e2bf88..26af7d848b9703b1ddee153eec0c55e606e6ae5d 100644 (file)
@@ -107,6 +107,10 @@ static void recff_stitch(jit_State *J)
   const BCIns *pc = frame_pc(base-1);
   TValue *pframe = frame_prevl(base-1);
 
+  /* Check for this now. Throwing in lj_record_stop messes up the stack. */
+  if (J->cur.nsnap >= (MSize)J->param[JIT_P_maxsnap])
+    lj_trace_err(J, LJ_TRERR_SNAPOV);
+
   /* Move func + args up in Lua stack and insert continuation. */
   memmove(&base[1], &base[-1-LJ_FR2], sizeof(TValue)*nslot);
   setframe_ftsz(nframe, ((char *)nframe - (char *)pframe) + FRAME_CONT);