The code can be reduced to the following:
local function f()
local a = 1
end
f = load(string.dump(f, true))
local co = coroutine.create(f)
debug.sethook(co, function() end, "l")
coroutine.resume(co)
Looks like a problem with the "line event" hook for a bytecode without debug info.