于 2013-11-1 0:04, Bob Schiavo 写道:
By "interrupt a DEADLOOP inside tha Lua app_script", do you mean that
you want to load UNTRUSTED (potentially malicious) Lua code from outside,
and that you want to prevent the code from hanging your own code?
(i.e. you want to set an upper limit execution time for the that code)?
If so, I think it is possible. You may try this:
Install a LUA_HOOKCOUNT hook into the Lua VM, which would be called after
the VM had executed LIMIT instructions.
If the LIMIT is reached, you may throw an error and the control would return
to your main program.
Don't forget to remove the hook afterwards.
BTW, untrusted code should run in a sandbox.
If the sandbox allows protection points(i.e. pcall),
things might get complicated, but solutions still exist.