lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



We’ve come across an interesting behaviour when calling a function in the context of a coroutine that’s yielded. Our Lua Debugger programmer believes that there’s a bug in Lua, and has a proposed solution:


When executing code on a lua_State in a LUA_YIELD state, if the Lua traceexec function is called, the “L->state” variable remains LUA_YIELD after the traceexec call and unexpectedly interrupts execution.


Proposed solution in RED. File is lvm.c, starting on line 388 in luaV_execute


    if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) &&

        (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) {

      const lu_byte saved_status = L->status;

      L->status = 0;

      traceexec(L, pc);

      if (L->status == LUA_YIELD) {  /* did hook yield? */

        L->savedpc = pc - 1;



      L->status = saved_status;

      base = L->base;


Thank you, and thank you for Lua – we love it J