I think I have fixed a bug in LuaJ. Or, let's say, a difference in behavior compared to C-Lua. If you call error() in a debug hook, the error is not passed on to the coroutine as it should.
Fix (org/luaj/vm2/lib/DebugLib.java, replace the whole function):
void callHook(LuaValue type, LuaValue arg) {
LuaThread t = globals.running;
t.inhook = true;
try {
t.hookfunc.call(type, arg);
// XXX (Stefan) - following two lines commented out should fix timeout bug (using debug.hook for timeouts)
/*} catch (Exception e) {
e.printStackTrace();*/
} finally {
t.inhook = false;
}
}
After fixing this, debug hooks can be used to cancel too long-running Lua calculations. (Very important if you need proper, i.e. tight, sandboxing.)
I'm waiting for Jim to confirm that this bug fix is OK.
Cheers,
Stefan Reich
(TinyBrain.de)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi!
I think I have fixed a bug in LuaJ. Or, let's say, a difference in behavior compared to C-Lua. If you call error() in a debug hook, the error is not passed on to the coroutine as it should.
Fix (org/luaj/vm2/lib/DebugLib.java, replace the whole function):
After fixing this, debug hooks can be used to cancel too long-running Lua calculations. (Very important if you need proper, i.e. tight, sandboxing.)
I'm waiting for Jim to confirm that this bug fix is OK.
Cheers,
Stefan Reich
(TinyBrain.de)