How can I correctly use Lua::init_from_ptr
?
#430
Answered
by
khvzak
shanebishop
asked this question in
Q&A
-
I am getting a segfault when trying to use
use libc::c_int;
use mlua::lua_State;
use mlua::prelude::*;
#[no_mangle]
pub unsafe extern "C" fn luaopen_libmlua_repro(l: *mut lua_State) -> c_int {
eprintln!("luaopen_li stderr print");
let _lua = Lua::init_from_ptr(l);
1
}
[package]
name = "mlua-repro"
version = "0.1.0"
edition = "2021"
[dependencies]
mlua = { version = "0.9.9", features = ["lua52"] }
libc = "0.2"
[lib]
crate-type = ["cdylib"]
require 'libmlua_repro' Build and run:
How can I correctly use |
Beta Was this translation helpful? Give feedback.
Answered by
khvzak
Jul 29, 2024
Replies: 1 comment 1 reply
-
to use in modules mlua must be compiled with |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
shanebishop
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
to use in modules mlua must be compiled with
module
feature flag.Otherwise it try to close state and free memory when constructed
Lua
goes out of scope.