Bug: Yielding in a hook stops in the wrong instruction
Yielding in a hook must decrease the program counter, because it already counted an instruction that, in the end, was not executed. However, that decrement should be done only when about to restart the thread. Otherwise, inspecting the thread with the debug library shows it one instruction behind of where it really is.
This commit is contained in:
4
ldo.c
4
ldo.c
@@ -792,6 +792,10 @@ static void resume (lua_State *L, void *ud) {
|
||||
lua_assert(L->status == LUA_YIELD);
|
||||
L->status = LUA_OK; /* mark that it is running (again) */
|
||||
if (isLua(ci)) { /* yielded inside a hook? */
|
||||
/* undo increment made by 'luaG_traceexec': instruction was not
|
||||
executed yet */
|
||||
lua_assert(ci->callstatus & CIST_HOOKYIELD);
|
||||
ci->u.l.savedpc--;
|
||||
L->top.p = firstArg; /* discard arguments */
|
||||
luaV_execute(L, ci); /* just continue running Lua code */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user