lua-users home
lua-l archive

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


Looks like a bug... I seem to get a hang when I type in your sample
Lua code into a Lua console (this is on Linux, compiled w/ gcc).  I'll
look into it.  It looks as though the yield stuff may not be getting
cleaned up properly after an error.  If I do:

lua> function my_func() yield() end
lua> my_func() print(10)
yielded, now resuming...
10
lua>

which looks correct.  But "if (nil > nil) then end" by itself gives a
Lua error, "error: attempt to compare two nil values".  So I'm
guessing that the callinfo stack is invalid after an error.

Actually there's at least one more bug... subsequent entries of
"my_func() print(10)" cause a yield error.

-T

On Jan 04, 2002 at 07:34 +0100, Arvid Norberg wrote:
> When I run the following program, it will be caught in an infinite-loop
> trying to pop the callinfo stack (line 514 in ldo.c). It looks like the
> L->callinfostack
> points to the stackframe below baseci. So all stack frames are popped
> and eventually the callinfostack is set to 0. From there, there's no return.
> 
> extern "C"
> {
>     #include "lua.h"
>     #include "lualib.h"
> }
> 
> #include <windows.h>
> 
> int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, INT)
> {
>     lua_State *L = lua_open(1000);
>     lua_baselibopen(L);
> 
>     lua_dostring(L, "function my_func() yield() end");
> 
>     // call my_func() and then do something illegal (that will cause a
> runtime-error)
>     lua_dostring(L, "my_func() if (nil > nil) then end");
> 
>     // now, execute the code that causes a runtime-error
>     // this call does not return
>     lua_resume(L);
> 
>     lua_close(L);
>     return 0;
> }
> 
> It seems to be a windows-specific problem. It will only occur when
> compiled as a Win32 application. If I compile the program as a Win32 console
> application it works as expected.
> 
> I'm using lua 4.0 with the yield-patch.
> 
> ---
> Arvid Norberg

-- 
Thatcher Ulrich <tu@tulrich.com>
http://tulrich.com