diff options
author | Mike Pall <mike> | 2024-08-15 00:17:19 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2024-08-15 00:17:19 +0200 |
commit | 86e7123bb1782a5f200ba5e83b8c4f3fbad4f7bc (patch) | |
tree | 888c82fdb96028b92ec4f49c6f6efdab0895ccf3 | |
parent | 7369eff67d46d7f5fac9ee064e3fbf97a15458de (diff) | |
download | luajit-86e7123bb1782a5f200ba5e83b8c4f3fbad4f7bc.tar.gz luajit-86e7123bb1782a5f200ba5e83b8c4f3fbad4f7bc.tar.bz2 luajit-86e7123bb1782a5f200ba5e83b8c4f3fbad4f7bc.zip |
Different fix for partial snapshot restore due to stack overflow.
Reported by Junlong Li. Fixed by Peter Cawley. #1196
-rw-r--r-- | src/lj_snap.c | 3 | ||||
-rw-r--r-- | src/lj_trace.c | 4 |
2 files changed, 3 insertions, 4 deletions
diff --git a/src/lj_snap.c b/src/lj_snap.c index 9858c110..0c317b52 100644 --- a/src/lj_snap.c +++ b/src/lj_snap.c | |||
@@ -873,7 +873,8 @@ const BCIns *lj_snap_restore(jit_State *J, void *exptr) | |||
873 | lua_State *L = J->L; | 873 | lua_State *L = J->L; |
874 | 874 | ||
875 | /* Set interpreter PC to the next PC to get correct error messages. */ | 875 | /* Set interpreter PC to the next PC to get correct error messages. */ |
876 | setcframe_pc(cframe_raw(L->cframe), pc+1); | 876 | setcframe_pc(L->cframe, pc+1); |
877 | setcframe_pc(cframe_raw(cframe_prev(L->cframe)), pc); | ||
877 | 878 | ||
878 | /* Make sure the stack is big enough for the slots from the snapshot. */ | 879 | /* Make sure the stack is big enough for the slots from the snapshot. */ |
879 | if (LJ_UNLIKELY(L->base + snap->topslot >= tvref(L->maxstack))) { | 880 | if (LJ_UNLIKELY(L->base + snap->topslot >= tvref(L->maxstack))) { |
diff --git a/src/lj_trace.c b/src/lj_trace.c index 8385f3d1..d015f2ab 100644 --- a/src/lj_trace.c +++ b/src/lj_trace.c | |||
@@ -788,10 +788,8 @@ int LJ_FASTCALL lj_trace_exit(jit_State *J, void *exptr) | |||
788 | exd.J = J; | 788 | exd.J = J; |
789 | exd.exptr = exptr; | 789 | exd.exptr = exptr; |
790 | errcode = lj_vm_cpcall(L, NULL, &exd, trace_exit_cp); | 790 | errcode = lj_vm_cpcall(L, NULL, &exd, trace_exit_cp); |
791 | if (errcode) { | 791 | if (errcode) |
792 | setcframe_pc(cframe_raw(L->cframe), L); /* Point to any valid memory. */ | ||
793 | return -errcode; /* Return negated error code. */ | 792 | return -errcode; /* Return negated error code. */ |
794 | } | ||
795 | 793 | ||
796 | lj_vmevent_send(L, TEXIT, | 794 | lj_vmevent_send(L, TEXIT, |
797 | lj_state_checkstack(L, 4+RID_NUM_GPR+RID_NUM_FPR+LUA_MINSTACK); | 795 | lj_state_checkstack(L, 4+RID_NUM_GPR+RID_NUM_FPR+LUA_MINSTACK); |