Patrick Barrett
2014-09-13 01:09:01 UTC
Not sure if this is actual bug or if everything is just being JITed away, but
it's unexpected
behavior none the less.
Setting a debug hook to trigger on a function that does a while(1) without any
significant
code inside the loop will never trigger the debug hook. Note, adding a print
statement to the
loop in the test code, below, does have the debug hook trigger.
Tested in 2.0.3 and git HEAD. Does not occur in PUC-Rio 5.2.3 (ie, hook does
trigger).
Test Case:
-----------------------------------------------------------------
CPU_TIME_LIMIT = 0.0001
function fn()
while true do
end
end
local execution_time_limiter = function()
local start_time = os.clock()
return function()
if os.clock() - start_time > CPU_TIME_LIMIT then
error("killed", 0)
end
end
end
local co = coroutine.create(fn)
debug.sethook(co, execution_time_limiter(), "", 1000)
local status, err = coroutine.resume(co)
print(status, err)
-----------------------------------------------------------------
it's unexpected
behavior none the less.
Setting a debug hook to trigger on a function that does a while(1) without any
significant
code inside the loop will never trigger the debug hook. Note, adding a print
statement to the
loop in the test code, below, does have the debug hook trigger.
Tested in 2.0.3 and git HEAD. Does not occur in PUC-Rio 5.2.3 (ie, hook does
trigger).
Test Case:
-----------------------------------------------------------------
CPU_TIME_LIMIT = 0.0001
function fn()
while true do
end
end
local execution_time_limiter = function()
local start_time = os.clock()
return function()
if os.clock() - start_time > CPU_TIME_LIMIT then
error("killed", 0)
end
end
end
local co = coroutine.create(fn)
debug.sethook(co, execution_time_limiter(), "", 1000)
local status, err = coroutine.resume(co)
print(status, err)
-----------------------------------------------------------------