RuntimeTerminated(TerminationDetails::BlockOnNeedsAsync)
shjunma opened this issue · 2 comments
thread 'main' panicked at 'called Result::unwrap()
on an Err
value: RuntimeTerminated(TerminationDetails::BlockOnNeedsAsync)'
lucet version is latest master branch
git clone https://github.com/bytecodealliance/lucet.git
Follow is my steps:
cd ~/workplace
mkdir hello
cd hello
vim hello.c
#include <stdio.h>
int main(void)
{
puts("Hello world");
return 0;
}
wasm32-wasi-clang -Ofast -o hello.wasm hello.c
lucetc-wasi -o hello.so hello.wasm
lucet-wasi hello.so
output:
Hello world
cd lucet/docs/lucet-runtime-example
cp hello.so into docs/lucet-runtime-example/
src/main.rs content:
use lucet_runtime::{DlModule, Limits, MmapRegion, Region};
use lucet_wasi::WasiCtxBuilder;
fn main() {
// ensure the WASI symbols are exported from the final executable
lucet_wasi::export_wasi_funcs();
// load the compiled Lucet module
let dl_module = DlModule::load("hello.so").unwrap();
// create a new memory region with default limits on heap and stack size
let region = MmapRegion::create(1, &Limits::default().with_heap_memory_size(100 * 16 * 64 * 1024)).unwrap();
// instantiate the module in the memory region
let mut instance = region.new_instance(dl_module).unwrap();
// prepare the WASI context, inheriting stdio handles from the host executable
let wasi_ctx = WasiCtxBuilder::new().inherit_stdio().build();
instance.insert_embed_ctx(wasi_ctx);
// run the WASI main function
instance.run("_start", &[]).unwrap();
}
project files:
drwxr-xr-x 4 root root 4096 Jul 8 12:50 ./
drwxr-xr-x 4 root root 4096 Jul 8 11:23 ../
drwxr-xr-x 2 root root 4096 Jul 8 11:23 .cargo/
-rw-r--r-- 1 root root 290 Jul 8 11:23 Cargo.toml
-rwxr-xr-x 1 root root 389216 Jul 8 12:27 example.so*
-rwxr-xr-x 1 root root 39016 Jul 8 12:50 hello.so*
drwxr-xr-x 2 root root 4096 Jul 8 12:51 src/
cargo run
Result:
Compiling lucet-runtime-example v0.1.0 (/home/ubuntu/workplace/lucet/docs/lucet-runtime-example)
Finished dev [unoptimized + debuginfo] target(s) in 10.30s
Running /home/ubuntu/workplace/lucet/target/debug/lucet-runtime-example
thread 'main' panicked at 'called Result::unwrap()
on an Err
value: RuntimeTerminated(TerminationDetails::BlockOnNeedsAsync)', docs/lucet-runtime-example/src/main.rs:17:33
Who can tell me why? thanks a lot
Thanks for this report. lucet-runtime-example
is incorrect here, and this never got caught because it is not tested in CI. Since #655, any use of lucet-wasi
requires instances be run as async
inside the tokio runtime.
We realize this restriction is pretty heavy, but lucet is approaching its EOL and lucet isn't structured to make supporting both sync and async versions of wasi easy. We recommend users transition to our sister project, wasmtime, which at this point supports everything lucet does, as well as many new wasm features which lucet does not. Wasmtime supports wasi both on sync rust and on top of tokio.
I got it, thanks very much for your reply.