summaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
authorkyren <kerriganw@gmail.com>2017-06-25 16:52:32 -0400
committerkyren <kerriganw@gmail.com>2017-06-25 17:15:11 -0400
commitd3b311fe49e6d88798982f8d6281b7300b84eec1 (patch)
tree60211e51ef28a705a8004259b6b2d25cf120ae4e /src/error.rs
parentbf9bf849c2a03768eb9b9609893ea3a75c8d2bcd (diff)
downloadmlua-d3b311fe49e6d88798982f8d6281b7300b84eec1.zip
Another major API change, out of stack space is not an Err
It, ahem "should not" be possible to exhaust lua stack space in normal usage, and causing stack errors to be Err is slightly obnoxious. I have been wanting to make this change for a while, and removing the callback API from tables makes this sensible *I think*. I can think of a couple of ways that this is not technically true, but I think that they are acceptable, or should be handled differently. One, you can make arbitrarily sized LuaVariadic values. I think this is maybe a bug already, because there is an argument limit in Lua which is lower than the stack limit. I'm not sure what happens there, but if it is a stack based panic, (or any panic?) it is a bug. Two, I believe that if you recurse over and over between lua -> rust -> lua -> rust etc, and call rlua API functions, you might get a stack panic. I think for trusted lua code, this is morally equivalent to a regular stack overflow in plain rust, which is already.. well it's not a panic but it's some kind of safe crash I'm not sure, so I think this is acceptable. For *untrusted* lua code, this could theoretically be a problem if the API provided a callback that would call back into lua, then some lua script could force a stack based panic. There are so many concerns with untrusted lua code, and this library is NOT safe enough yet for untrusted code (it doesn't even provide an option to limit lua to the safe API subset yet!), so this is not currently an issue. When the library provides support for "safe lua", it should come with big warnings anyway, and being able to force a stack panic is pretty minor in comparison. I think if there are other ways to cause unbounded stack usage, that it is a bug, or there can be an error just for that situation, like argument count limits. This commit also fixes several stupid bugs with tests, stack checking, and panics.
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs5
1 files changed, 0 insertions, 5 deletions
diff --git a/src/error.rs b/src/error.rs
index 89289ea..e7822c6 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -19,9 +19,6 @@ pub enum LuaError {
ToLuaConversionError(String),
/// A generic Lua -> Rust conversion error.
FromLuaConversionError(String),
- /// Insufficient Lua stack space, only generated from rust when calling
- /// `lua_checkstack`.
- StackOverflow,
/// A `LuaThread` was resumed and the coroutine was no longer active.
CoroutineInactive,
/// A `LuaUserData` is not the expected type in a borrow.
@@ -57,7 +54,6 @@ impl fmt::Display for LuaError {
&LuaError::FromLuaConversionError(ref msg) => {
write!(fmt, "Error converting lua type to rust: {}", msg)
}
- &LuaError::StackOverflow => write!(fmt, "Lua out of stack space"),
&LuaError::CoroutineInactive => write!(fmt, "Cannot resume inactive coroutine"),
&LuaError::UserDataTypeMismatch => write!(fmt, "Userdata not expected type"),
&LuaError::UserDataBorrowError => write!(fmt, "Userdata already mutably borrowed"),
@@ -79,7 +75,6 @@ impl Error for LuaError {
&LuaError::ErrorError(_) => "lua error handling error",
&LuaError::ToLuaConversionError(_) => "conversion error to lua",
&LuaError::FromLuaConversionError(_) => "conversion error from lua",
- &LuaError::StackOverflow => "lua stack overflow",
&LuaError::CoroutineInactive => "lua coroutine inactive",
&LuaError::UserDataTypeMismatch => "lua userdata type mismatch",
&LuaError::UserDataBorrowError => "lua userdata already mutably borrowed",