lua-users home
lua-l archive

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



> > It is tricky to get this bug, because this field (`pc') is used only
> for
> > debug/error report. The attached code shows the bug in Lua5.0.  BTW,
> > maybe this explains your previous problems with linehooks in
> coroutines!
> 
> It's not tricky to replicate, not sure how tricky it is to fix! Thanks
> for the pointers I'll continue this line of inquiry. I've been working
> on the assumption that we had some erroneous data or a dodgy pointer
in
> the game until now.
> 
> > I am quite busy until next week, so I cannot test all these now. But
> as
> > soon as I have more time I will double check all this stuff.
> 
> Great. I'll try modifying the code as you suggest. On first attempt it
> appears that removing the assertion and putting the above line where
you
> suggest doesn't solve the problem.

It does indeed seem to explain the problem. I retract the above
statement; my juggling code around caused a fail not caused by you. We
now seem to have coroutines yielding as we require. The assertion still
fails but as you point out it probably shouldn't be there. When we
remove it everything seems to work as you'd expect.

I copied (rather than moved) the line setting the callinfo PC in case
it's needed by the call hook callback. I'm not going to delve any
further as I just don't have the time (Terminator 3 is on in 10 minutes
- gah those cyborgs just don't know when to quit).

Regards,
Nick


------>8------>8------>8------>8------>8---


StkId luaV_execute (lua_State *L) {
  LClosure *cl;
  TObject *k;
  const Instruction *pc;
 callentry:  /* entry point when calling new functions */
  L->ci->u.l.pc = &pc;       // ************************************
  if (L->hookmask & LUA_MASKCALL)
    luaD_callhook(L, LUA_HOOKCALL, -1);
 retentry:  /* entry point when returning to old functions */
  L->ci->u.l.pc = &pc;       // ************************************
  lua_assert(L->ci->state == CI_SAVEDPC ||
             L->ci->state == (CI_SAVEDPC | CI_CALLING));
  L->ci->state = CI_HASFRAME;  /* activate frame */
  pc = L->ci->u.l.savedpc;
  cl = &clvalue(L->base - 1)->l;
  k = cl->p->k;
  /* main loop of interpreter */