]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
FFI: Fix line info for result conversion errors in callbacks.
authorMike Pall <mike>
Fri, 25 Nov 2011 18:25:44 +0000 (19:25 +0100)
committerMike Pall <mike>
Fri, 25 Nov 2011 18:35:58 +0000 (19:35 +0100)
src/lj_ccallback.c
src/lj_debug.c

index 597b3c11f09f016b1ce557790f37d39b9a5580d4..f8d95d39b1a2884635d74a8cf22a67ac315055a4 100644 (file)
@@ -377,7 +377,7 @@ void LJ_FASTCALL lj_ccallback_leave(CTState *cts, TValue *o)
   fn = curr_func(L);
   if (isluafunc(fn)) {
     GCproto *pt = funcproto(fn);
-    setcframe_pc(L->cframe, proto_bc(pt)+pt->sizebc);
+    setcframe_pc(L->cframe, proto_bc(pt)+pt->sizebc+1);
   }
   callback_conv_result(cts, L, o);
   /* Finally drop C frame and continuation frame. */
index 4038e2098a22565bb8223594b17dfffc109c79f1..89434aaf8db31a5719bcc1f6446858673d1dcbdd 100644 (file)
@@ -90,7 +90,7 @@ static BCPos debug_framepc(lua_State *L, GCfunc *fn, cTValue *nextframe)
   pt = funcproto(fn);
   pos = proto_bcpos(pt, ins) - 1;
 #if LJ_HASJIT
-  if (pos >= pt->sizebc) {  /* Undo the effects of lj_trace_exit for JLOOP. */
+  if (pos > pt->sizebc) {  /* Undo the effects of lj_trace_exit for JLOOP. */
     GCtrace *T = (GCtrace *)((char *)(ins-1) - offsetof(GCtrace, startins));
     lua_assert(bc_isret(bc_op(ins[-1])));
     pos = proto_bcpos(pt, mref(T->startpc, const BCIns));
@@ -105,9 +105,9 @@ static BCPos debug_framepc(lua_State *L, GCfunc *fn, cTValue *nextframe)
 BCLine LJ_FASTCALL lj_debug_line(GCproto *pt, BCPos pc)
 {
   const void *lineinfo = proto_lineinfo(pt);
-  if (pc < pt->sizebc && lineinfo) {
+  if (pc <= pt->sizebc && lineinfo) {
     BCLine first = pt->firstline;
-    if (pc == pt->sizebc-1) return first + pt->numline;
+    if (pc == pt->sizebc) return first + pt->numline;
     if (pc-- == 0) return first;
     if (pt->numline < 256)
       return first + (BCLine)((const uint8_t *)lineinfo)[pc];