From e86ef9d755452058f66d0b6d08f00fdb5867d45d Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Wed, 4 Jan 2023 16:15:23 +0000 Subject: [PATCH 01/16] v0.8.7 --- CHANGELOG.md | 7 +++++++ Cargo.toml | 2 +- src/lib.rs | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62535ccd..360614e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## v0.8.7 + +- Minimum Luau updated to 0.555 (`LUAI_MAXCSTACK` limit increased to 100000) +- `_VERSION` in Luau now includes version number +- Fixed lifetime of `DebugNames` in `Debug::names()` and `DebugSource` in `Debug::source()` +- Fixed subtraction overflow when calculating index for `MultiValue::get()` + ## v0.8.6 - Fixed bug when recycled Registry slot can be set to Nil diff --git a/Cargo.toml b/Cargo.toml index c228275b..e86b2be3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mlua" -version = "0.8.6" # remember to update html_root_url and mlua_derive +version = "0.8.7" # remember to update html_root_url and mlua_derive authors = ["Aleksandr Orlenko ", "kyren "] edition = "2021" repository = "https://github.com/khvzak/mlua" diff --git a/src/lib.rs b/src/lib.rs index 24208b8f..d766de49 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -72,7 +72,7 @@ //! [`serde::Deserialize`]: https://docs.serde.rs/serde/de/trait.Deserialize.html // mlua types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/mlua/0.8.6")] +#![doc(html_root_url = "https://docs.rs/mlua/0.8.7")] // Deny warnings inside doc tests / examples. When this isn't present, rustdoc doesn't show *any* // warnings at all. #![doc(test(attr(deny(warnings))))] From c108dc821316b175fb2e4c08415a8353779b6685 Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Mon, 6 Feb 2023 23:46:31 +0000 Subject: [PATCH 02/16] Force protected mode for long enough strings --- src/util.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util.rs b/src/util.rs index 45a47f50..18a77771 100644 --- a/src/util.rs +++ b/src/util.rs @@ -245,7 +245,8 @@ pub unsafe fn pop_error(state: *mut ffi::lua_State, err_code: c_int) -> Error { // Uses 3 (or 1 if unprotected) stack spaces, does not call checkstack. #[inline(always)] pub unsafe fn push_string(state: *mut ffi::lua_State, s: &[u8], protect: bool) -> Result<()> { - if protect { + // Always use protected mode if the string is too long + if protect || s.len() > (1 << 30) { protect_lua!(state, 0, 1, |state| { ffi::lua_pushlstring(state, s.as_ptr() as *const c_char, s.len()); }) From c9715aa5d95717d4a92bed86e76e58aa26c36f29 Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Wed, 22 Feb 2023 20:15:40 +0000 Subject: [PATCH 03/16] Fix potential deadlock when trying to reuse dropped RegistryKey. If no free registry id found, we call protect_lua! macro while keeping mutex guard to the unref list. Protected calls can trigger garbage collection and if RegistryKey is placed in userdata being collected, this can lead to deadlock. The solution is drop mutex guard as soon as possible. Also this commit includes optimization in creating reference in Lua registry. --- src/lua.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/lua.rs b/src/lua.rs index d1001dec..4daa7800 100644 --- a/src/lua.rs +++ b/src/lua.rs @@ -2072,22 +2072,27 @@ impl Lua { let _sg = StackGuard::new(self.state); check_stack(self.state, 4)?; - let unref_list = (*self.extra.get()).registry_unref_list.clone(); self.push_value(t)?; // Try to reuse previously allocated slot - let unref_list2 = unref_list.clone(); - let mut unref_list2 = mlua_expect!(unref_list2.lock(), "unref list poisoned"); - if let Some(registry_id) = unref_list2.as_mut().and_then(|x| x.pop()) { + let unref_list = (*self.extra.get()).registry_unref_list.clone(); + let free_registry_id = mlua_expect!(unref_list.lock(), "unref list poisoned") + .as_mut() + .and_then(|x| x.pop()); + if let Some(registry_id) = free_registry_id { // It must be safe to replace the value without triggering memory error ffi::lua_rawseti(self.state, ffi::LUA_REGISTRYINDEX, registry_id as Integer); return Ok(RegistryKey::new(registry_id, unref_list)); } // Allocate a new RegistryKey - let registry_id = protect_lua!(self.state, 1, 0, |state| { - ffi::luaL_ref(state, ffi::LUA_REGISTRYINDEX) - })?; + let registry_id = if self.unlikely_memory_error() { + ffi::luaL_ref(self.state, ffi::LUA_REGISTRYINDEX) + } else { + protect_lua!(self.state, 1, 0, |state| { + ffi::luaL_ref(state, ffi::LUA_REGISTRYINDEX) + })? + }; Ok(RegistryKey::new(registry_id, unref_list)) } } From bc194981fc845d246630e8bb1bd2e2462b56b1bf Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Sat, 4 Mar 2023 11:58:34 +0000 Subject: [PATCH 04/16] Optimize userdata methods call when __index and fields_getters are nil --- src/util.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/util.rs b/src/util.rs index 18a77771..24b9dc34 100644 --- a/src/util.rs +++ b/src/util.rs @@ -428,11 +428,17 @@ unsafe fn init_userdata_metatable_index(state: *mut ffi::lua_State) -> Result<() } ffi::lua_pop(state, 1); - // Create and cache `__index` helper + // Create and cache `__index` generator let code = cstr!( r#" local error, isfunction = ... return function (__index, field_getters, methods) + -- Fastpath to return methods table for index access + if __index == nil and field_getters == nil then + return methods + end + + -- Alternatively return a function for index access return function (self, key) if field_getters ~= nil then local field_getter = field_getters[key] @@ -482,7 +488,7 @@ pub unsafe fn init_userdata_metatable_newindex(state: *mut ffi::lua_State) -> Re } ffi::lua_pop(state, 1); - // Create and cache `__newindex` helper + // Create and cache `__newindex` generator let code = cstr!( r#" local error, isfunction = ... From 34679e105d0af449a8a8749ca9c2d06aa012d13d Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Sun, 5 Mar 2023 17:50:53 +0000 Subject: [PATCH 05/16] v0.8.8 --- CHANGELOG.md | 5 +++++ Cargo.toml | 2 +- README.md | 2 +- src/lib.rs | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 360614e8..2043c9d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## v0.8.8 + +- Fix potential deadlock when trying to reuse dropped registry keys. +- Optimize userdata methods call when __index and fields_getters are nil + ## v0.8.7 - Minimum Luau updated to 0.555 (`LUAI_MAXCSTACK` limit increased to 100000) diff --git a/Cargo.toml b/Cargo.toml index e86b2be3..ebd5fb67 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mlua" -version = "0.8.7" # remember to update html_root_url and mlua_derive +version = "0.8.8" # remember to update html_root_url and mlua_derive authors = ["Aleksandr Orlenko ", "kyren "] edition = "2021" repository = "https://github.com/khvzak/mlua" diff --git a/README.md b/README.md index 211da8b6..9cdf895f 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [crates.io]: https://crates.io/crates/mlua [API Documentation]: https://docs.rs/mlua/badge.svg [docs.rs]: https://docs.rs/mlua -[Coverage Status]: https://codecov.io/gh/khvzak/mlua/branch/master/graph/badge.svg?token=99339FS1CG +[Coverage Status]: https://codecov.io/gh/khvzak/mlua/branch/v0.8/graph/badge.svg?token=99339FS1CG [codecov.io]: https://codecov.io/gh/khvzak/mlua [MSRV]: https://img.shields.io/badge/rust-1.56+-brightgreen.svg?&logo=rust diff --git a/src/lib.rs b/src/lib.rs index d766de49..a67b9d10 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -72,7 +72,7 @@ //! [`serde::Deserialize`]: https://docs.serde.rs/serde/de/trait.Deserialize.html // mlua types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/mlua/0.8.7")] +#![doc(html_root_url = "https://docs.rs/mlua/0.8.8")] // Deny warnings inside doc tests / examples. When this isn't present, rustdoc doesn't show *any* // warnings at all. #![doc(test(attr(deny(warnings))))] From eb84284824575a371a266f8be7e2b7050d8385c0 Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Tue, 16 May 2023 22:12:36 +0100 Subject: [PATCH 06/16] Fix ref_stack_exhaustion test (Lua 5.4.6) --- tests/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests.rs b/tests/tests.rs index 7d246563..0161d9e6 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(()) From bfdb4087b8954c95a1c49df4fc693df56bb7b22f Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Tue, 16 May 2023 22:49:49 +0100 Subject: [PATCH 07/16] Update minimal (vendored) Lua 5.4 to 5.4.6 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index ebd5fb67..50663d53 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,7 +56,7 @@ parking_lot = { version = "0.12", optional = true } [build-dependencies] cc = { version = "1.0" } pkg-config = { version = "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.0", optional = true } From 5a96e80266a172870acc7b5fe90a12ac3361878e Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Tue, 16 May 2023 22:50:46 +0100 Subject: [PATCH 08/16] Use lua_closethread instead of lua_resetthread in vendored mode (introduced in Lua 5.4.6) --- src/ffi/lua54/lua.rs | 3 +++ src/lua.rs | 4 +++- src/thread.rs | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ffi/lua54/lua.rs b/src/ffi/lua54/lua.rs index f124c377..218255e3 100644 --- a/src/ffi/lua54/lua.rs +++ b/src/ffi/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 4daa7800..d8931509 100644 --- a/src/lua.rs +++ b/src/lua.rs @@ -1738,8 +1738,10 @@ impl Lua { let extra = &mut *self.extra.get(); if extra.recycled_thread_cache.len() < extra.recycled_thread_cache.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 c0a42605..cb1b67e6 100644 --- a/src/thread.rs +++ b/src/thread.rs @@ -201,8 +201,10 @@ impl<'lua> Thread<'lua> { lua.push_ref(&self.0); let thread_state = ffi::lua_tothread(lua.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, lua.state); #[cfg(feature = "lua54")] if status != ffi::LUA_OK { return Err(pop_error(thread_state, status)); From 72de17bf47ffa1d3634d0af5c294c1b2e9780415 Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Mon, 10 Apr 2023 01:49:51 +0100 Subject: [PATCH 09/16] Allow deserializing Lua null into unit(`()`) or unit struct. See #264 --- src/serde/de.rs | 24 +++++++++++++++++++++++- tests/serde.rs | 23 ++++++++++++++++++----- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/serde/de.rs b/src/serde/de.rs index 376bd94c..b3bb43b2 100644 --- a/src/serde/de.rs +++ b/src/serde/de.rs @@ -327,9 +327,31 @@ impl<'lua, 'de> serde::Deserializer<'de> for Deserializer<'lua> { visitor.visit_newtype_struct(self) } + #[inline] + fn deserialize_unit(self, visitor: V) -> Result + where + V: de::Visitor<'de>, + { + match self.value { + Value::LightUserData(ud) if ud.0.is_null() => visitor.visit_unit(), + _ => self.deserialize_any(visitor), + } + } + + #[inline] + fn deserialize_unit_struct(self, _name: &'static str, visitor: V) -> Result + where + V: de::Visitor<'de>, + { + match self.value { + Value::LightUserData(ud) if ud.0.is_null() => visitor.visit_unit(), + _ => self.deserialize_any(visitor), + } + } + serde::forward_to_deserialize_any! { bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string bytes - byte_buf unit unit_struct identifier ignored_any + byte_buf identifier ignored_any } } diff --git a/tests/serde.rs b/tests/serde.rs index e161493b..1a11fa53 100644 --- a/tests/serde.rs +++ b/tests/serde.rs @@ -391,31 +391,44 @@ fn test_from_value_newtype_struct() -> Result<(), Box> { #[test] fn test_from_value_enum() -> Result<(), Box> { let lua = Lua::new(); + lua.globals().set("null", lua.null())?; #[derive(Deserialize, PartialEq, Debug)] - enum E { + struct UnitStruct; + + #[derive(Deserialize, PartialEq, Debug)] + enum E { Unit, Integer(u32), Tuple(u32, u32), Struct { a: u32 }, + Wrap(T), } let value = lua.load(r#""Unit""#).eval()?; - let got = lua.from_value(value)?; + let got: E = lua.from_value(value)?; assert_eq!(E::Unit, got); let value = lua.load(r#"{Integer = 1}"#).eval()?; - let got = lua.from_value(value)?; + let got: E = lua.from_value(value)?; assert_eq!(E::Integer(1), got); let value = lua.load(r#"{Tuple = {1, 2}}"#).eval()?; - let got = lua.from_value(value)?; + let got: E = lua.from_value(value)?; assert_eq!(E::Tuple(1, 2), got); let value = lua.load(r#"{Struct = {a = 3}}"#).eval()?; - let got = lua.from_value(value)?; + let got: E = lua.from_value(value)?; assert_eq!(E::Struct { a: 3 }, got); + let value = lua.load(r#"{Wrap = null}"#).eval()?; + let got = lua.from_value(value)?; + assert_eq!(E::Wrap(UnitStruct), got); + + let value = lua.load(r#"{Wrap = null}"#).eval()?; + let got = lua.from_value(value)?; + assert_eq!(E::Wrap(()), got); + Ok(()) } From 573d71345f95beb91b1226be889f124160a5c107 Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Tue, 16 May 2023 22:55:29 +0100 Subject: [PATCH 10/16] Don't set html_root_url (it's not recommended) --- Cargo.toml | 2 +- src/lib.rs | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 50663d53..d0584ebc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mlua" -version = "0.8.8" # remember to update html_root_url and mlua_derive +version = "0.8.8" # remember to update mlua_derive authors = ["Aleksandr Orlenko ", "kyren "] edition = "2021" repository = "https://github.com/khvzak/mlua" diff --git a/src/lib.rs b/src/lib.rs index a67b9d10..e8caa360 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -71,8 +71,6 @@ //! [`serde::Serialize`]: https://docs.serde.rs/serde/ser/trait.Serialize.html //! [`serde::Deserialize`]: https://docs.serde.rs/serde/de/trait.Deserialize.html -// mlua types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/mlua/0.8.8")] // Deny warnings inside doc tests / examples. When this isn't present, rustdoc doesn't show *any* // warnings at all. #![doc(test(attr(deny(warnings))))] From 765117c2bb1f0dbea159b7652b6ec9295e423bc6 Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Wed, 12 Apr 2023 00:34:26 +0100 Subject: [PATCH 11/16] Update tarpaulin settings --- .github/workflows/coverage.yml | 2 +- tarpaulin.toml | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tarpaulin.toml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 647f2aa7..bc34a0e1 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -14,7 +14,7 @@ jobs: - name: Generate coverage report run: | - cargo tarpaulin --verbose --features lua54,vendored,async,send,serialize,macros --out xml --exclude-files benches --exclude-files build --exclude-files mlua_derive --exclude-files src/ffi --exclude-files tests + cargo tarpaulin --out xml --tests --exclude-files benches/* --exclude-files src/ffi/*/* - name: Upload report to codecov.io uses: codecov/codecov-action@v3 diff --git a/tarpaulin.toml b/tarpaulin.toml new file mode 100644 index 00000000..f5f71b4f --- /dev/null +++ b/tarpaulin.toml @@ -0,0 +1,8 @@ +[lua54_coverage] +features = "lua54,vendored,async,serialize,macros" + +[lua51_coverage] +features = "lua51,vendored,async,serialize,macros" + +[luau_coverage] +features = "luau,async,serialize,macros" From 15e353a7f841c8c4707a0635d8794c088506eca3 Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Tue, 16 May 2023 22:59:45 +0100 Subject: [PATCH 12/16] v0.8.9 --- CHANGELOG.md | 6 ++++++ Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2043c9d0..938fa984 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v0.8.9 + +- Update minimal (vendored) Lua 5.4 to 5.4.6 +- Use `lua_closethread` instead of `lua_resetthread` in vendored mode (Lua 5.4.6) +- Allow deserializing Lua null into unit (`()`) or unit struct. + ## v0.8.8 - Fix potential deadlock when trying to reuse dropped registry keys. diff --git a/Cargo.toml b/Cargo.toml index d0584ebc..306b4ea7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mlua" -version = "0.8.8" # remember to update mlua_derive +version = "0.8.9" # remember to update mlua_derive authors = ["Aleksandr Orlenko ", "kyren "] edition = "2021" repository = "https://github.com/khvzak/mlua" From e4eeee05c404a08642e6c5ae3d7c84f0709c9619 Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Wed, 16 Aug 2023 00:09:20 +0100 Subject: [PATCH 13/16] Pin (more strict) lua-src and luajit-src versions --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 306b4ea7..f96a1c7a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,8 +56,8 @@ parking_lot = { version = "0.12", optional = true } [build-dependencies] cc = { version = "1.0" } pkg-config = { version = "0.3.17" } -lua-src = { version = ">= 546.0.0, < 550.0.0", optional = true } -luajit-src = { version = ">= 210.4.0, < 220.0.0", optional = true } +lua-src = { version = ">= 546.0.0, < 546.1.0", optional = true } +luajit-src = { version = ">= 210.4.0, < 210.5.0", optional = true } luau0-src = { version = "0.5.0", optional = true } [dev-dependencies] From c9099a43644d02c9c56f592d62e2d872924922ef Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Wed, 16 Aug 2023 00:15:05 +0100 Subject: [PATCH 14/16] Update to Luau 0.590 --- Cargo.toml | 2 +- src/chunk.rs | 1 + src/ffi/luau/luacode.rs | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f96a1c7a..f71223ae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,7 +58,7 @@ cc = { version = "1.0" } pkg-config = { version = "0.3.17" } lua-src = { version = ">= 546.0.0, < 546.1.0", optional = true } luajit-src = { version = ">= 210.4.0, < 210.5.0", optional = true } -luau0-src = { version = "0.5.0", optional = true } +luau0-src = { version = "0.7.0", optional = true } [dev-dependencies] rustyline = "10.0" diff --git a/src/chunk.rs b/src/chunk.rs index bd24ae4b..1766dfa8 100644 --- a/src/chunk.rs +++ b/src/chunk.rs @@ -228,6 +228,7 @@ impl Compiler { coverageLevel: self.coverage_level as c_int, vectorLib: vector_lib.map_or(ptr::null(), |s| s.as_ptr()), vectorCtor: vector_ctor.map_or(ptr::null(), |s| s.as_ptr()), + vectorType: ptr::null(), mutableGlobals: mutable_globals_ptr, }; ffi::luau_compile(source.as_ref(), options) diff --git a/src/ffi/luau/luacode.rs b/src/ffi/luau/luacode.rs index 571db4c2..853e0946 100644 --- a/src/ffi/luau/luacode.rs +++ b/src/ffi/luau/luacode.rs @@ -10,7 +10,8 @@ pub struct lua_CompileOptions { pub coverageLevel: c_int, pub vectorLib: *const c_char, pub vectorCtor: *const c_char, - pub mutableGlobals: *mut *const c_char, + pub vectorType: *const c_char, + pub mutableGlobals: *const *const c_char, } extern "C" { From 032d4af896d6934c45321d0abc0fa562a58cdef1 Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Sat, 22 Jul 2023 18:44:44 +0100 Subject: [PATCH 15/16] Fix loading luau code starting with \t --- src/ffi/luau/compat.rs | 2 +- tests/tests.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ffi/luau/compat.rs b/src/ffi/luau/compat.rs index 043245a2..0ff8572a 100644 --- a/src/ffi/luau/compat.rs +++ b/src/ffi/luau/compat.rs @@ -341,7 +341,7 @@ pub unsafe fn luaL_loadbufferx( fn free(p: *mut c_void); } - let chunk_is_text = size == 0 || (*data as u8) >= b'\n'; + let chunk_is_text = size == 0 || (*data as u8) >= b'\t'; if !mode.is_null() { let modeb = CStr::from_ptr(mode).to_bytes(); if !chunk_is_text && !modeb.contains(&b'b') { diff --git a/tests/tests.rs b/tests/tests.rs index 0161d9e6..d20b9da9 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -69,7 +69,7 @@ fn test_safety() -> Result<()> { fn test_load() -> Result<()> { let lua = Lua::new(); - let func = lua.load("return 1+2").into_function()?; + let func = lua.load("\treturn 1+2").into_function()?; let result: i32 = func.call(())?; assert_eq!(result, 3); From 84811b1be3072ec0add905b7b617ee27218b7c16 Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Wed, 16 Aug 2023 00:20:05 +0100 Subject: [PATCH 16/16] v0.8.10 --- CHANGELOG.md | 6 ++++++ Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 938fa984..31e151ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v0.8.10 + +- Update to Luau 0.590 (luau0-src to 0.7.x) +- Fix loading luau code starting with \t +- Pin lua-src and luajit-src versions + ## v0.8.9 - Update minimal (vendored) Lua 5.4 to 5.4.6 diff --git a/Cargo.toml b/Cargo.toml index f71223ae..dd94454b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mlua" -version = "0.8.9" # remember to update mlua_derive +version = "0.8.10" # remember to update mlua_derive authors = ["Aleksandr Orlenko ", "kyren "] edition = "2021" repository = "https://github.com/khvzak/mlua"