]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Avoid assertion in case of stack overflow from stitched trace.
authorMike Pall <mike>
Sun, 27 Nov 2022 14:25:32 +0000 (15:25 +0100)
committerMike Pall <mike>
Sun, 27 Nov 2022 14:25:32 +0000 (15:25 +0100)
Reported by Sergey Bronnikov. Fixed by Sergey Kaplun.

src/lj_debug.c

index 112f53583d392ccc0d0cba3854cbc14520667688..ca893153e0f6410eeb19f48efbadc2a2b77d6fa3 100644 (file)
@@ -101,9 +101,12 @@ static BCPos debug_framepc(lua_State *L, GCfunc *fn, cTValue *nextframe)
   pos = proto_bcpos(pt, ins) - 1;
 #if LJ_HASJIT
   if (pos > pt->sizebc) {  /* Undo the effects of lj_trace_exit for JLOOP. */
-    GCtrace *T = (GCtrace *)((char *)(ins-1) - offsetof(GCtrace, startins));
-    lj_assertL(bc_isret(bc_op(ins[-1])), "return bytecode expected");
-    pos = proto_bcpos(pt, mref(T->startpc, const BCIns));
+    if (bc_isret(bc_op(ins[-1]))) {
+      GCtrace *T = (GCtrace *)((char *)(ins-1) - offsetof(GCtrace, startins));
+      pos = proto_bcpos(pt, mref(T->startpc, const BCIns));
+    } else {
+      pos = NO_BCPOS;  /* Punt in case of stack overflow for stitched trace. */
+    }
   }
 #endif
   return pos;