I was running across this issue in my project last week.
See Stackoverflow question here and reddit.com/r/rust thread here
Basically, calling HashMap::new() inside my runtime-dynamically-loaded plugin lib is causing an unwind, and then rust segfaults while doing the unwind. Running the application on the command line gives Illegal Instruction output, running inside gdb gives:
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff51a0c60 in ?? ()
I've produced a minimal test case:
main.rs
use std::dynamic_lib::DynamicLibrary;
use std::mem;
fn main()
{
let p1 = match DynamicLibrary::open(Some("libplugin.so")) {
Ok(lib) => lib,
Err(error) => panic!("Could not load the library: {}", error)
};
let s1: extern "Rust" fn() = unsafe {
match p1.symbol("init") {
Err(error) => panic!("Could not load function init: {}", error),
Ok(init) => mem::transmute::<*mut u8, _>(init)
}
};
s1();
}
plugin.rs
use std::collections::hashmap::{HashMap};
use std::collections::treemap::{TreeMap};
#[no_mangle]
pub fn init()
{
let h:HashMap<&str, &str> = HashMap::new();
//let t:TreeMap<&str, &str> = TreeMap::new();
println!("Loaded!");
}
Changing HashMap to TreeMap in plugin.rs causes the segfault to go away, and the program runs correctly.
Im using the latest Rust master codebase, compiled on linux x64.
I was running across this issue in my project last week.
See Stackoverflow question here and reddit.com/r/rust thread here
Basically, calling HashMap::new() inside my runtime-dynamically-loaded plugin lib is causing an unwind, and then rust segfaults while doing the unwind. Running the application on the command line gives
Illegal Instructionoutput, running inside gdb gives:I've produced a minimal test case:
main.rs
plugin.rs
Changing HashMap to TreeMap in plugin.rs causes the segfault to go away, and the program runs correctly.
Im using the latest Rust master codebase, compiled on linux x64.