diff --git a/mlua-sys/Cargo.toml b/mlua-sys/Cargo.toml index b78bfb4..4887249 100644 --- a/mlua-sys/Cargo.toml +++ b/mlua-sys/Cargo.toml @@ -35,6 +35,6 @@ module = [] cc = "1.0" cfg-if = "1.0" pkg-config = "0.3.17" -lua-src = { version = ">= 544.0.0, < 550.0.0", optional = true } +lua-src = { version = ">= 546.0.0, < 550.0.0", optional = true } luajit-src = { version = ">= 210.4.0, < 220.0.0", optional = true } luau0-src = { version = "0.5.6", optional = true } diff --git a/mlua-sys/src/lua54/lua.rs b/mlua-sys/src/lua54/lua.rs index f124c37..218255e 100644 --- a/mlua-sys/src/lua54/lua.rs +++ b/mlua-sys/src/lua54/lua.rs @@ -112,7 +112,10 @@ extern "C" { pub fn lua_newstate(f: lua_Alloc, ud: *mut c_void) -> *mut lua_State; pub fn lua_close(L: *mut lua_State); pub fn lua_newthread(L: *mut lua_State) -> *mut lua_State; + // Deprecated in Lua 5.4.6 pub fn lua_resetthread(L: *mut lua_State) -> c_int; + #[cfg(feature = "vendored")] + pub fn lua_closethread(L: *mut lua_State, from: *mut lua_State) -> c_int; pub fn lua_atpanic(L: *mut lua_State, panicf: lua_CFunction) -> lua_CFunction; diff --git a/src/lua.rs b/src/lua.rs index 89ab6f1..2ebce1b 100644 --- a/src/lua.rs +++ b/src/lua.rs @@ -1671,8 +1671,10 @@ impl Lua { let extra = &mut *self.extra.get(); if extra.thread_pool.len() < extra.thread_pool.capacity() { let thread_state = ffi::lua_tothread(extra.ref_thread, thread.0.index); - #[cfg(feature = "lua54")] + #[cfg(all(feature = "lua54", not(feature = "vendored")))] let status = ffi::lua_resetthread(thread_state); + #[cfg(all(feature = "lua54", feature = "vendored"))] + let status = ffi::lua_closethread(thread_state, self.state()); #[cfg(feature = "lua54")] if status != ffi::LUA_OK { // Error object is on top, drop it diff --git a/src/thread.rs b/src/thread.rs index 21271db..8db3e35 100644 --- a/src/thread.rs +++ b/src/thread.rs @@ -232,8 +232,10 @@ impl<'lua> Thread<'lua> { lua.push_ref(&self.0); let thread_state = ffi::lua_tothread(state, -1); - #[cfg(feature = "lua54")] + #[cfg(all(feature = "lua54", not(feature = "vendored")))] let status = ffi::lua_resetthread(thread_state); + #[cfg(all(feature = "lua54", feature = "vendored"))] + let status = ffi::lua_closethread(thread_state, state); #[cfg(feature = "lua54")] if status != ffi::LUA_OK { return Err(pop_error(thread_state, status)); diff --git a/tests/tests.rs b/tests/tests.rs index 17fae25..57763f5 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -991,7 +991,7 @@ fn test_ref_stack_exhaustion() { match catch_unwind(AssertUnwindSafe(|| -> Result<()> { let lua = Lua::new(); let mut vals = Vec::new(); - for _ in 0..1000000 { + for _ in 0..10000000 { vals.push(lua.create_table()?); } Ok(())