> Investigation of a "typed Lua" for compilation is something on the roadmap. That is the approach that the main Lua project is taking to compete with LuaJIT on performance. I haven't heard anything about an official "typed Lua". Is there information about it somewhere?
* Typed Lua: https://github.com/andremm/typedlua (not actively maintained) * tl: https://github.com/teal-language/tl a compiler for Teal a typed dialect of lua. (actively maintained)
Lua in the Kernel?
41–49 of 49 posts
Re: Lua in the Kernel?
#42Earlier quoted context omitted.
I'd be surprised if it could prevent a script from running indefinitely. In particular, limiting the number of Lua bytecode instructions is insufficient FTA: “Lua has a facility to interrupt a script after it has run a certain number of instructions.”
Just add a time limit to the sandbox as well
Re: Lua in the Kernel?
#43Earlier quoted context omitted.
I'd be surprised if it could prevent a script from running indefinitely. In particular, limiting the number of Lua bytecode instructions is insufficient FTA: “Lua has a facility to interrupt a script after it has run a certain number of instructions.”
string.find is implemented in C, not Lua. As far as Lua is concerned, that call is a single instruction.
Through always under the assumption that the C function is implemented correctly and adding need to do some explicit budged keeping makes it more complex and in turn more prone to errors.
Re: Lua in the Kernel?
#44It's only a matter of time until we have metered WebAssembly in the kernel :)
Re: Lua in the Kernel?
#45Earlier quoted context omitted.
You can't prevent infinite loops unless you've solved the halting problem right? They could of course just limit the run time if they really wanted to make sure scripts don't run indefinitely.
The halting problem only says that you cannot tell if a program ever stops, i.e. takes a finite number of steps but without any a priori bounds. If you limit the number of steps to N, you can just run N steps of the program on your given input and look if it has stopped already.
Re: Lua in the Kernel?
#46Re: Lua in the Kernel?
#47Earlier quoted context omitted.
> You can't prevent infinite loops unless you've solved the halting problem right? Only in general arbitrary turing complete runtimes. For restricted subsets of instructions and specific implementations of runtimes you can. E.g. one could trivially disallow "jump" control flow, and limit loops to N iterations.
It's more simple than that: pull the plug on the entire turing machine. Lua runs in a VM, so you can stop it from the outside, which wouldn't be possible if the code was running directly in the CPU (Without an OS underneath it, that is).
Re: Lua in the Kernel?
#48Earlier quoted context omitted.
The halting problem only says that you cannot tell if a program ever stops, i.e. takes a finite number of steps but without any a priori bounds. If you limit the number of steps to N, you can just run N steps of the program on your given input and look if it has stopped already.
The problem only says you can’t tell if the programs stops without actually running it. But here you’re running it anyway.
Re: Lua in the Kernel?
#49Earlier quoted context omitted.
Yes. `string.find` is implemented in C. Invoking it (no matter how complex its arguments) requires just a few bytecode instructions.
Well, then that's library dependent and not an intrinsic part of the language. So shipping Lua safely would mean having to swap or drop parts of the standard library for something a bit more robust. Apparently, that's what Lunatik does so the work seems to already have been done.