Reported by Junlong Li. Fixed by Peter Cawley. #1196
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))) {
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);