silentbicycle/lunatest

err_handler assumes the passed arg (e) is a table

Closed this issue · 5 comments

err_handler assumes that its passed argument is a table. But...

If the argument passed to err_handler is not a table (and somehow I'm able to trigger this if I call error from within my code) then Lua gets upset when it's used as a table, and throws an error, which is caught by error_handler, which continues until the Lua stack overflows. The fix is simple; check that e is a table:

local function err_handler(name)
   return function (e)
             if type(e) == 'table' and e.type and ok_types[e.type()] then return e end
             local msg = fmt("ERROR in %s():\n\t%s", name, tostring(e))
             msg = debug.traceback(msg, 3)
             return Error { msg=msg }
          end
end

Good catch. Just checking if it's a table seems to cause other issues with error reporting, I will investigate further.

Any progress on this? I tried my patch against the latest sources and didn't see any additional failures in the output of running test.lua.

Thanks.

Sorry this has taken so long. I'm looking into it now. While checking that e is a table seems to treat the symptom, I want to determine the root cause as well.

You're right, it is just a type handling error, easily reproduced.

thanks!