[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Assert in VM
- From: Roberto Ierusalimschy <roberto@...>
- Date: Tue, 08 Jul 2003 10:39:23 -0300
> Please correct me swiftly if this is wrong. If this is true, it should
> have been pointed out in the manual, and is a severe limitation/bug in
> Lua.
It seems that that assertion is wrong. Of course when we return to a
function it does not need to be running on the same C frame it was
before. That is the whole point of coroutines in Lua: That you *can*
"call a C function, which calls Lua to create a coroutine and then
resume your coroutine (once), yield and return to C, then resume the
coroutine through C from a different point."
Besides the assertion, the initialization of that field may be wrong also.
The line
> callentry: /* entry point when calling new functions */
- L->ci->u.l.pc = &pc;
should be here:
> retentry: /* entry point when returning to old functions */
+ L->ci->u.l.pc = &pc;
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!
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.
-- Roberto
function g(x)
coroutine.yield(x)
end
function f (i)
debug.sethook(print, "l")
for j=1,1000 do
g(i+j)
end
end
co = coroutine.wrap(f)
co(10)
pcall(co)
pcall(co)