Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on empty source #281

Closed
xNxExOx opened this issue Sep 25, 2023 · 2 comments
Closed

Crash on empty source #281

xNxExOx opened this issue Sep 25, 2023 · 2 comments

Comments

@xNxExOx
Copy link

xNxExOx commented Sep 25, 2023

moinimal example:

let file = ""; // loaded from actual file, but that file can by empty
// ...
        lua.context(|state|{
            state.load(file.as_bytes())
                .exec()
        })?;

produces this error:

thread 'main' panicked at 'rlua internal error: 1 too many stack values popped (this is a bug, please file an issue)', .cargo\registry\src\index.crates.io-6f17d22bba15001f\rlua-0.19.5\src\util.rs:59:17
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library\std\src\panicking.rs:593
   1: core::panicking::panic_fmt
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library\core\src\panicking.rs:67
   2: rlua::util::impl$1::drop
             at .cargo\registry\src\index.crates.io-6f17d22bba15001f\rlua-0.19.5\src\util.rs:59
   3: core::ptr::drop_in_place
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be\library\core\src\ptr\mod.rs:497
   4: rlua::context::Context::load_chunk
             at .cargo\registry\src\index.crates.io-6f17d22bba15001f\rlua-0.19.5\src\context.rs:902
   5: rlua::context::Chunk::into_function
             at .cargo\registry\src\index.crates.io-6f17d22bba15001f\rlua-0.19.5\src\context.rs:988
   6: rlua::context::Chunk::call
             at .cargo\registry\src\index.crates.io-6f17d22bba15001f\rlua-0.19.5\src\context.rs:981
   7: rlua::context::Chunk::exec
             at .cargo\registry\src\index.crates.io-6f17d22bba15001f\rlua-0.19.5\src\context.rs:950
   8: script_validator::validate_with_lua::closure$0

Easy workaround for me is just wrap it with if !file.is_empty(), so not an critical issue for me.

@jugglerchris
Copy link
Collaborator

Thanks for the report.
This seems to work on Lua 5.4 (the default) but does indeed panic with Lua 5.1 as above. I'll look into it, thanks!

@jugglerchris
Copy link
Collaborator

I believe I've got a fix for the issue: #284

jugglerchris added a commit that referenced this issue Oct 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants