-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
Description
I got a error in console: Segmentation fault (core dumped)
A fast reproduce: https://github.com/LoongBuns/wamr-rust-sdk/tree/ohno/examples/wasm-wild
Run with this wasm https://github.com/wasm3/wasm-coremark/blob/main/coremark-minimal.wasm
I'm not quite sure what I need to enable to get iwasm to understand my needs, as this doesn't fail with other runtimes coremark .
use core::error::Error;
use core::ffi::c_void;
use core::result::Result;
use wamr_rust_sdk::{
function::Function, instance::Instance, module::Module, runtime::Runtime, value::WasmValue,
};
extern "C" fn clock_ms_host() -> i64 {
use std::time::{SystemTime, UNIX_EPOCH};
SystemTime::now()
.duration_since(UNIX_EPOCH)
.expect("Clock may have gone backwards")
.as_millis() as i64
}
impl Runtime {
pub fn builder_with_module_name(name: &str) -> RuntimeBuilder {
let args = RuntimeInitArgs::default();
RuntimeBuilder {
args,
host_functions: HostFunctionList::new(name),
}
}
}
pub fn wamr_coremark() -> Result<f32, Box<dyn Error>> {
let coremark_wasm = include_bytes!("https://github.com/wasm3/wasm-coremark/blob/main/coremark-minimal.wasm");
let runtime = Runtime::builder_with_module_name("env")
.use_system_allocator()
.run_as_interpreter()
.register_host_function("clock_ms", clock_ms_host as *mut c_void)
.build()?;
let module = Module::from_vec(&runtime, Vec::from(&coremark_wasm), "")?;
let instance = Instance::new(&runtime, &module, 2 * 1024)?;
let function = Function::find_export_func(&instance, "run")?;
if let WasmValue::F32(res) = function.call(&instance, &vec![])? {
Ok(res)
} else {
panic!("Failed running coremark in wasmr");
}
}
Metadata
Metadata
Assignees
Labels
No labels