Skip to content

Assertion failed on mlua 0.11.0 #615

@sxyazi

Description

@sxyazi

First of all, congratulations on the new release, you really did an outstanding job, @khvzak! 🎉🎉

I'm upgrading my project to mlua 0.11.0 and encountered an error:

Assertion failed: ((L->top.p <= L->ci->top.p) && "stack overflow"), function lua_pushnil, file lapi.c, line 500.

Minimal reproducer (run in debug mode):

use mlua::{Lua, Result, Table};

fn main() -> Result<()> {
  fn tbl_with_mt(lua: &Lua) -> Result<Table> {
    let tbl = lua.create_table()?;
    tbl.set_metatable(Some(lua.create_table()?))?;
    Ok(tbl)
  }

  let lua = Lua::new();
  let _: Vec<Table> = (0..10000).map(|_| tbl_with_mt(&lua)).collect::<Result<_>>()?;
  Ok(())
}
[dependencies]
mlua = { version = "0.11.0", features = [ "lua54", "vendored" ] }

Here's the full backtrace:

Stop reason: hit program assert
> bt
* thread #1, name = 'main', queue = 'com.apple.main-thread', stop reason = hit program assert
  * frame #0: 0x000000018200c764 libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x0000000182043c28 libsystem_pthread.dylib`pthread_kill + 288
    frame #2: 0x0000000181f51ae8 libsystem_c.dylib`abort + 180
    frame #3: 0x0000000181f50e44 libsystem_c.dylib`__assert_rtn + 272
    frame #4: 0x0000000101b54218 yazi`lua_pushnil(L=0x0000000105048008) at lapi.c:500:3
    frame #5: 0x0000000101ab81b0 yazi`mlua::state::raw::RawLua::drop_ref(self=0x0000000105043450, vref=0x000000016fdf46c0) at raw.rs:843:9
    frame #6: 0x0000000101ae3164 yazi`<mlua::types::value_ref::ValueRef as core::ops::drop::Drop>::drop(self=0x000000016fdf46c0) at value_ref.rs:56:30
    frame #7: 0x0000000101ac2ab8 yazi`core::ptr::drop_in_place<mlua::types::value_ref::ValueRef>((null)=0x000000016fdf46c0) at mod.rs:799:1
    frame #8: 0x0000000101ac20e0 yazi`core::ptr::drop_in_place<mlua::table::Table>((null)=0x000000016fdf46c0) at mod.rs:799:1
    frame #9: 0x0000000101ae0afc yazi`mlua::table::Table::set_metatable(self=0x000000016fdf4b30, metatable=Option<mlua::table::Table> @ 0x000000016fdf4d10) at table.rs:515:13
    frame #10: 0x00000001007c78fc yazi`yazi_plugin::loader::require::Require::create_mt(lua=0x000000010504ac68, id="folder-rules", mod=Table @ 0x000000016fdf5510, sync=true) at require.rs:66:6
    frame #11: 0x0000000100976ff4 yazi`yazi_plugin::loader::require::Require::install::{{closure}}((null)=0x0000000000000001, lua=0x000000010504ac68, id=String @ 0x000000016fdf5790) at require.rs:22:5
    frame #12: 0x0000000100b5ed50 yazi`mlua::state::Lua::create_function::{{closure}}(rawlua=0x0000000105043450, nargs=1) at state.rs:1264:13
    frame #13: 0x0000000101ac58e0 yazi`<alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call(self=0x0000000105074380, args=(&mlua::state::raw::RawLua, i32) @ 0x000000016fdf5898) at boxed.rs:1985:9
    frame #14: 0x0000000101abc294 yazi`mlua::state::raw::RawLua::create_callback::call_callback::{{closure}}(extra=0x000000010504ab90, nargs=1) at raw.rs:1191:39
    frame #15: 0x0000000101acdb9c yazi`mlua::state::util::callback_error_ext::{{closure}} at util.rs:108:9
    frame #16: 0x0000000101aa68e8 yazi`<core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once(self=<unavailable>, (null)=<unavailable>) at unwind_safe.rs:272:9
    frame #17: 0x0000000101acef1c yazi`std::panicking::catch_unwind::do_call(data=6171876320) at panicking.rs:589:40
    frame #18: 0x0000000101a99804 yazi`__rust_try + 32
    frame #19: 0x0000000101a92064 yazi`std::panic::catch_unwind [inlined] std::panicking::catch_unwind(f=<unavailable>) at panicking.rs:552:19
    frame #20: 0x0000000101a92024 yazi`std::panic::catch_unwind(f=<unavailable>) at panic.rs:359:14
    frame #21: 0x0000000101accbc8 yazi`mlua::state::util::callback_error_ext(state=0x000000010588c008, extra=0x000000010504ab90, wrap_error=true, f={closure_env#0} @ 0x000000016fdf60d0) at util.rs:105:11
    frame #22: 0x0000000101abc0e8 yazi`mlua::state::raw::RawLua::create_callback::call_callback(state=0x000000010588c008) at raw.rs:1186:13
    frame #23: 0x0000000101b6838c yazi`precallC(L=0x000000010588c008, func=0x0000000105894a40, nresults=1, f=0x0000000101abc044) at ldo.c:536:7
    frame #24: 0x0000000101b68680 yazi`luaD_precall(L=0x000000010588c008, func=0x0000000105894a40, nresults=1) at ldo.c:599:7
    frame #25: 0x0000000101b350c0 yazi`luaV_execute(L=0x000000010588c008, ci=0x000000010504ae10) at lvm.c:1685:22
    frame #26: 0x0000000101b68a60 yazi`ccall(L=0x000000010588c008, func=0x0000000105049030, nResults=-1, inc=65537) at ldo.c:644:5
    frame #27: 0x0000000101b68ab0 yazi`luaD_callnoyield(L=0x000000010588c008, func=0x0000000105049030, nResults=-1) at ldo.c:662:3
    frame #28: 0x0000000101b5732c yazi`f_call(L=0x000000010588c008, ud=0x000000016fdf7208) at lapi.c:1038:3
    frame #29: 0x0000000101b66de4 yazi`luaD_rawrunprotected(L=0x000000010588c008, f=0x0000000101b572f8, ud=0x000000016fdf7208) at ldo.c:141:3
    frame #30: 0x0000000101b69580 yazi`luaD_pcall(L=0x000000010588c008, func=0x0000000101b572f8, u=0x000000016fdf7208, old_top=32, ef=16) at ldo.c:964:12
    frame #31: 0x0000000101b571d0 yazi`lua_pcallk(L=0x000000010588c008, nargs=0, nresults=-1, errfunc=1, ctx=0, k=0x0000000000000000) at lapi.c:1064:14
    frame #32: 0x0000000101aabb28 yazi`mlua::function::Function::call [inlined] mlua_sys::lua54::lua::lua_pcall(L=0x000000010588c008, n=0, r=-1, f=1) at lua.rs:278:5
    frame #33: 0x0000000101aabb1c yazi`mlua::function::Function::call(self=0x000000016fdf7590, args=<unavailable>) at function.rs:121:23
    frame #34: 0x0000000101ad84dc yazi`mlua::chunk::Chunk::call(self=<unavailable>, args=<unavailable>) at chunk.rs:627:31
    frame #35: 0x0000000101ad8414 yazi`mlua::chunk::Chunk::exec(self=<unavailable>) at chunk.rs:570:14
    frame #36: 0x0000000100b7e294 yazi`yazi_plugin::lua::stage_2(lua=0x0000000102a50038) at lua.rs:64:36
    frame #37: 0x0000000100b7c494 yazi`yazi_plugin::lua::init_lua at lua.rs:14:2
    frame #38: 0x000000010075cf48 yazi`yazi_plugin::init at lib.rs:9:2
    frame #39: 0x0000000100029228 yazi`yazi::main::{{closure}}((null)=0x000000016fdf90e8) at main.rs:35:2
    frame #40: 0x000000010019dddc yazi`tokio::runtime::park::CachedParkThread::block_on::{{closure}} at park.rs:285:71
    frame #41: 0x000000010019d91c yazi`tokio::runtime::park::CachedParkThread::block_on [inlined] tokio::task::coop::with_budget(budget=Budget @ 0x000000016fdf997b, f={closure_env#0}<yazi::main::{async_block_env#0}> @ 0x000000016fdf9980) at mod.rs:167:5
    frame #42: 0x000000010019d8c8 yazi`tokio::runtime::park::CachedParkThread::block_on [inlined] tokio::task::coop::budget(f={closure_env#0}<yazi::main::{async_block_env#0}> @ 0x000000016fdf9958) at mod.rs:133:5
    frame #43: 0x000000010019d850 yazi`tokio::runtime::park::CachedParkThread::block_on(self=0x000000016fdf99ef, f={async_block_env#0} @ 0x000000016fdf99f0) at park.rs:285:31
    frame #44: 0x00000001000e979c yazi`tokio::runtime::context::blocking::BlockingRegionGuard::block_on(self=0x000000016fdfaad0, f={async_block_env#0} @ 0x000000016fdfa240) at blocking.rs:66:14
    frame #45: 0x0000000100029db8 yazi`tokio::runtime::scheduler::multi_thread::MultiThread::block_on::{{closure}}(blocking=0x000000016fdfaad0) at mod.rs:87:22
    frame #46: 0x0000000100121310 yazi`tokio::runtime::context::runtime::enter_runtime(handle=0x000000016fdfe4f0, allow_block_in_place=true, f={closure_env#0}<yazi::main::{async_block_env#0}> @ 0x000000016fdfb348) at runtime.rs:65:16
    frame #47: 0x0000000100029d0c yazi`tokio::runtime::scheduler::multi_thread::MultiThread::block_on(self=0x000000016fdfe4c8, handle=0x000000016fdfe4f0, future=<unavailable>) at mod.rs:86:9
    frame #48: 0x000000010009b578 yazi`tokio::runtime::runtime::Runtime::block_on_inner(self=0x000000016fdfe4c0, future={async_block_env#0} @ 0x000000016fdfd468, (null)=SpawnMeta @ 0x000000016fdfcbce) at runtime.rs:358:50
    frame #49: 0x000000010009b8dc yazi`tokio::runtime::runtime::Runtime::block_on(self=0x000000016fdfe4c0, future={async_block_env#0} @ 0x000000016fdfe640) at runtime.rs:330:18
    frame #50: 0x00000001000ecdd0 yazi`yazi::main at main.rs:40:20
    frame #51: 0x0000000100005d70 yazi`core::ops::function::FnOnce::call_once((null)=0x00000001000eccdc, (null)=<unavailable>) at function.rs:253:5
    frame #52: 0x00000001000e9144 yazi`std::sys::backtrace::__rust_begin_short_backtrace(f=0x00000001000eccdc) at backtrace.rs:152:18
    frame #53: 0x00000001000d07cc yazi`std::rt::lang_start::{{closure}} at rt.rs:206:18
    frame #54: 0x0000000101b9a2d0 yazi`std::rt::lang_start_internal [inlined] core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once at function.rs:290:21 [opt]
    frame #55: 0x0000000101b9a2c8 yazi`std::rt::lang_start_internal [inlined] std::panicking::catch_unwind::do_call at panicking.rs:589:40 [opt]
    frame #56: 0x0000000101b9a2c4 yazi`std::rt::lang_start_internal [inlined] std::panicking::catch_unwind at panicking.rs:552:19 [opt]
    frame #57: 0x0000000101b9a2c4 yazi`std::rt::lang_start_internal [inlined] std::panic::catch_unwind at panic.rs:359:14 [opt]
    frame #58: 0x0000000101b9a2c4 yazi`std::rt::lang_start_internal [inlined] std::rt::lang_start_internal::{{closure}} at rt.rs:175:24 [opt]
    frame #59: 0x0000000101b99dbc yazi`std::rt::lang_start_internal [inlined] std::panicking::catch_unwind::do_call at panicking.rs:589:40 [opt]
    frame #60: 0x0000000101b99dbc yazi`std::rt::lang_start_internal [inlined] std::panicking::catch_unwind at panicking.rs:552:19 [opt]
    frame #61: 0x0000000101b99dbc yazi`std::rt::lang_start_internal [inlined] std::panic::catch_unwind at panic.rs:359:14 [opt]
    frame #62: 0x0000000101b99dbc yazi`std::rt::lang_start_internal at rt.rs:171:5 [opt]
    frame #63: 0x00000001000d07a4 yazi`std::rt::lang_start(main=0x00000001000eccdc, argc=1, argv=6171914888, sigpipe=0) at rt.rs:205:5
    frame #64: 0x00000001000ece68 yazi`main + 36
    frame #65: 0x0000000181cebf28 dyld`start + 2236

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions