Comments (14)
@maxmcd, thanks so much for your help. This seems to be it 🙂
from wasmtime-go.
Ah yeah I believe that'll solve those issues. In that case I'll go ahead and close this issue.
from wasmtime-go.
Can you try changing this:
wasi, err := wasmtime.NewWasiInstance(store, wasiConfig, "wasi_unstable")
To this:
wasi, err := wasmtime.NewWasiInstance(store, wasiConfig, "wasi_snapshot_preview1")
I think that might do it.
from wasmtime-go.
Thanks. Does it mean the WASM binary was compiled against wasi_snapshot_preview1
?
the changed helped but now I get this
wasm trap: unreachable
wasm backtrace:
0: 0x9661 - <unknown>!std::panicking::rust_panic_with_hook::h3a0a1147e3efaaf2
1: 0xd6c4 - <unknown>!rust_begin_unwind
2: 0xd873 - <unknown>!core::panicking::panic_fmt::h6bf85cafed31336d
3: 0xcb57 - <unknown>!core::option::expect_none_failed::h7dfd2381e84fa608
4: 0x9bd1 - <unknown>!run_nom
from wasmtime-go.
Yes, I believe wasi_snapshot_preview1
is the current supported phase for rust. I think that is determined by this crate: https://github.com/bytecodealliance/wasi
Can you show your rust code? It looks like your code might be panicking on an option .unwrap
with option::expect_none_failed
? (or maybe something similar, not sure why it would be "expect_none".
from wasmtime-go.
Sure, this is the run_nom
method. And I already see an .unwrap()
🙈
#[no_mangle]
pub extern "C" fn run_nom() {
let data = std::fs::read_to_string("data/small_access.log").unwrap();
let p = nom::CommonLogParser { input: &data };
assert_eq!(p.count(), 161761);
}
EDIT: I changed the code to print the error failed to find a preopened file descriptor through which "data/small_access.log" could be opened
.
PreopenDir
has little documentation. What should the guest path be? I used .
for both paths.
from wasmtime-go.
Maybe better docs here: http://docs.wasmtime.dev/c-api/wasi_8h.html#a6d738a3510c5f3aa4a6f49d7bb658cd1
If you click into the Go src you can usually find which function is being called in the wasmtime C api.
Maybe try wasiConfig.PreopenDir(".", "/")
, the first path is the path on the host, the second path is where the directory is mounted for wasm.
from wasmtime-go.
Thanks for the link. Still no luck. I tried a few combinations such as wasiConfig.PreopenDir(".", "/")
and wasiConfig.PreopenDir("./data", "/data")
. I do get the same error when I try to use the wasmtime CLI wasmtime --dir=. target/wasm32-wasi/release/loki_bench.wasm --invoke run_nom
🤔
from wasmtime-go.
Can't get it working either. Maybe it's this issue? rust-lang/rust#79199
from wasmtime-go.
btw, in case it's unclear. I was able to get your code working by just using the parse.wasm output. Since the parse wasm binary isn't a lib it seems to work if I update nom := instance.GetExport("run_nom").Func()
to be nom := instance.GetExport("_start").Func()
That then runs this code: https://github.com/jeschkies/common-log-parser-bench/blob/karsten/go/src/bin/parse.rs#L5
And finds the right file
from wasmtime-go.
Thanks. That helped me with my original goal. I wanted to benchmark nom in WASM. How did you pass the argument to parse
?
from wasmtime-go.
To confirm, I think everything here's been figured out? Or are there lingering questions I could help resolve?
from wasmtime-go.
I'm not sure how to pass the main args to a WASM. However, that should be unrelated to this issue. I guess rust-lang/rust#79199 will solve this issue.
from wasmtime-go.
@jeschkies you might just want to use command line arguments or environment variables.
from wasmtime-go.
Related Issues (20)
- v3 build issues HOT 5
- Generating .wat file and errors when using .wat file generated from .wasm file. HOT 16
- Is it possible to dynamically link several wasm modules in Go host? HOT 6
- Works with wit-bindgen? HOT 3
- Out of bounds memory access panic HOT 5
- Support for ARM macs with bazel
- Allocation too large< ~lib/rt/itcms.ts<$Index out of range,~lib/rt.ts HOT 4
- Add changelog/releases info HOT 1
- SetMaxWasmStack fails with async_stack_size error HOT 6
- Please elaborate on installation instructions for unsupported platforms HOT 1
- Does debugging work when embedding in go like rust? HOT 1
- Equivalence for `WasiCtx.insert_file` from wasmtime_wasi Rust crate HOT 14
- Minor release HOT 4
- Windows build failure: undefined reference to `_setjmp' HOT 7
- Error out when using wasmtime-go to run Python code HOT 2
- Compilation failure on 32-bit systems HOT 3
- How to monitor memory usage HOT 4
- Go get latest version failed
- Missing V15 features.component_model in config HOT 3
- Support v16? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wasmtime-go.