lua-users home
lua-l archive

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

I am experiencing the following problem with Lua 5.0a:

I set the Lua (instruction) hook with count 10000, and
then pcall my Lua code which sometimes calls back to
my C++ which calls Lua again, with same state, but not
deeper than that. After my program seems to be stuck,
I check with debugger and notice that the hookcount
field is running down with negative numbers, and doesn't
match the ==0 condition in lvm.c.

I am pretty sure this is what happened:
The hookcount condition first matches in a second level
lua_pcall and triggers my hook function. This function
calls lua_error() after creating a "Timeout" message.

The lua_error() longjumps out and thus bypasses the resethook
macro in traceexec and leaves the hookcount field to zero.

My first level lua code now continues, and decrements the
hookcount without first checking that it already was zero.

It seems to me that this could be fixed by swapping the
folowing lines in traceexec (lvm.c):

     luaD_callhook(L, LUA_HOOKCOUNT, -1);

but I have not tested this yet, maybe there would be
other problems with this change?