2
0
Эх сурвалжийг харах

when thread yields, real "func" is in field 'extra', not in 'func'

Roberto Ierusalimschy 10 жил өмнө
parent
commit
e14a02c24f
1 өөрчлөгдсөн 8 нэмэгдсэн , 4 устгасан
  1. 8 4
      ltests.c

+ 8 - 4
ltests.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ltests.c,v 2.185 2014/09/04 18:15:29 roberto Exp roberto $
+** $Id: ltests.c,v 2.186 2014/10/01 11:54:56 roberto Exp roberto $
 ** Internal Module for Debugging of the Lua Implementation
 ** Internal Module for Debugging of the Lua Implementation
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -280,10 +280,14 @@ static void checkLclosure (global_State *g, LClosure *cl) {
 }
 }
 
 
 
 
-static int lua_checkpc (CallInfo *ci) {
+static int lua_checkpc (lua_State *L, CallInfo *ci) {
   if (!isLua(ci)) return 1;
   if (!isLua(ci)) return 1;
   else {
   else {
-    Proto *p = ci_func(ci)->p;
+    Proto *p;
+    if (L->status != LUA_YIELD || ci != L->ci)
+      p = ci_func(ci)->p;
+    else  /* real 'func' was saved in 'extra' field */
+      p = clLvalue(restorestack(L, ci->extra))->p;
     return p->code <= ci->u.l.savedpc &&
     return p->code <= ci->u.l.savedpc &&
            ci->u.l.savedpc <= p->code + p->sizecode;
            ci->u.l.savedpc <= p->code + p->sizecode;
   }
   }
@@ -299,7 +303,7 @@ static void checkstack (global_State *g, lua_State *L1) {
     lua_assert(upisopen(uv));  /* must be open */
     lua_assert(upisopen(uv));  /* must be open */
   for (ci = L1->ci; ci != NULL; ci = ci->previous) {
   for (ci = L1->ci; ci != NULL; ci = ci->previous) {
     lua_assert(ci->top <= L1->stack_last);
     lua_assert(ci->top <= L1->stack_last);
-    lua_assert(lua_checkpc(ci));
+    lua_assert(lua_checkpc(L1, ci));
   }
   }
   if (L1->stack) {
   if (L1->stack) {
     for (o = L1->stack; o < L1->top; o++)
     for (o = L1->stack; o < L1->top; o++)