alexcrichton opened issue #14581:
This input:
use std::sync::mpsc; use wasmtime::*; const WAT: &str = r#"(module (memory (export "m") 1) (data (i32.const 0) "hello") (func (export "f") (i32.store (i32.const 100) (i32.const 1))))"#; fn engine() -> Result<Engine> { let mut pool = PoolingAllocationConfig::default(); pool.memory_protection_keys(Enabled::Yes); pool.total_memories(32); pool.linear_memory_keep_resident(65536); let mut config = Config::new(); config.allocation_strategy(InstanceAllocationStrategy::Pooling(pool)); Engine::new(&config) } fn main() -> Result<()> { let (tx, rx) = mpsc::channel::<Store<()>>(); let pre = std::thread::spawn(move || { let store = rx.recv().unwrap(); eprintln!("dropping store on other thread..."); drop(store); eprintln!("dropped"); }); let engine = engine()?; let module = Module::new(&engine, WAT)?; let mut store = Store::new(&engine, ()); let instance = Instance::new(&mut store, &module, &[])?; instance .get_typed_func::<(), ()>(&mut store, "f")? .call(&mut store, ())?; tx.send(store).unwrap(); pre.join().unwrap(); Ok(()) }fails with:
$ cargo run Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.04s Running `target/debug/mpk-thread` dropping store on other thread... zsh: segmentation fault (core dumped) cargo runand this input:
use std::sync::mpsc; use wasmtime::*; const WAT: &str = r#"(module (memory (export "m") 1) (data (i32.const 0) "hello") (func (export "f") (i32.store (i32.const 100) (i32.const 1))))"#; fn engine() -> Result<Engine> { let mut pool = PoolingAllocationConfig::default(); pool.memory_protection_keys(Enabled::Yes); pool.total_memories(32); pool.linear_memory_keep_resident(65536); let mut config = Config::new(); config.allocation_strategy(InstanceAllocationStrategy::Pooling(pool)); Engine::new(&config) } fn main() -> Result<()> { let (tx, rx) = mpsc::channel::<Engine>(); let worker = std::thread::spawn(move || -> Result<()> { let engine = rx.recv().unwrap(); let module = Module::new(&engine, WAT)?; let mut store = Store::new(&engine, ()); let instance = Instance::new(&mut store, &module, &[])?; let mem = instance.get_memory(&mut store, "m").unwrap(); eprintln!("reading memory from pre-existing thread..."); eprintln!("data = {:?}", &mem.data(&store)[..5]); Ok(()) }); tx.send(engine()?).unwrap(); worker.join().unwrap()?; Ok(()) }fails with:
$ cargo run Compiling mpk-thread v0.1.0 (/home/alex/code/wasmtime2/reports/001-mpk-pkru-preexisting-thread-segv) Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.39s Running `target/debug/mpk-thread` reading memory from pre-existing thread... data = [zsh: segmentation fault (core dumped) cargo run
alexcrichton added the wasmtime:pooling-allocator label to Issue #14581.
fitzgen commented on issue #14581:
cc @jlb6740 @rahulchaphalkar
fitzgen added the bug label to Issue #14581.
Last updated: Oct 11 2026 at 04:10 UTC