Comments (4)
It looks like you need to enable WASI. You can find more about how to do this in our docs here. Can you try and report back, please? :)
from wasmex.
Yes I need WASL mode. After few attempts it still not work as expected. Again, I'm using the example from https://github.com/Shopify/javy.
When using wasmtime
cli, this is the output
~$ echo '{ "n": 2, "bar": "baz" }' | wasmtime test.wasm
{"foo":3,"newBar":"baz!"}
Here is Elixir code with wasmex
# wasm.exs
bytes = File.read!("test.wasm")
{:ok, pid} = Wasmex.start_link(%{bytes: bytes, wasi: %Wasmex.Wasi.WasiOptions{
args: ["{ \"n\": 2, \"bar\": \"baz\" }"]
}})
Wasmex.call_function(pid, :_start, []) |> IO.inspect()
When it runs, error occurs:
~$ mix run wasm.exs
{:error,
"Error during function excecution: `error while executing at wasm backtrace:\n 0: 0x13e0c - <unknown>!<wasm function 269>\n 1: 0x16bc - <unknown>!<wasm function 45>\n 2: 0x2406 - <unknown>!<wasm function 59>\n 3: 0xdd5b - <unknown>!<wasm function 174>\n 4: 0xd333 - <unknown>!<wasm function 173>\n 5: 0xdae - <unknown>!<wasm function 10>`."}
No matter I use wasi: true
or args
in WasiOptions
, both got me the same error message.
Why the wasmtime
cli isrunning fine but not in Elixir?
from wasmex.
@lok0613 I believe this is not a problem with wasmex but with the how the WASM program is started (and it's bad error handling).
According to the javy README, this example WASM program needs input on STDIN. You providedd args instead.
I tried this locally and it works for me using stdin:
{:ok, stdin} = Wasmex.Pipe.new()
{:ok, stdout} = Wasmex.Pipe.new()
wasi_options = %Wasmex.Wasi.WasiOptions{stdin: stdin, stdout: stdout}
{:ok, pid } = Wasmex.start_link(%{bytes: File.read!("/Users/tessi/dev/javy/index.wasm"), wasi: wasi_options})
Wasmex.Pipe.write(stdin, ~s({ "n": 2, "bar": "baz" }))
Wasmex.Pipe.seek(stdin, 0)
{:ok, _} = Wasmex.call_function(pid, :_start, [])
Wasmex.Pipe.seek(stdout, 0)
Wasmex.Pipe.read(stdout) # => "{\"foo\":3,\"newBar\":\"baz!\"}"
The error you posted is the stacktrace from a place within the WASM file. I guess it doesn't handle the case well when there is no input on stdin.
from wasmex.
closing this because it's not an issue with wasmex. thanks for trying wasmex out @lok0613 and for opening the ticket! it's always good to hear from people using it (and their problems) to learn about usability of wasmex. Also I learned about javy!
from wasmex.
Related Issues (20)
- Offer precompiled wasmex binaries HOT 3
- Require at least elixir 1.11 HOT 3
- Allow call_function to accept longer GenServer timeouts HOT 1
- Underlying Wasm runtime, wasmer -> wasmtime HOT 17
- Ability to cache compiled modules HOT 2
- How safe is it to run untrusted user wasm modules? HOT 2
- Example using WASI HOT 2
- Calls and execution model HOT 10
- Send and receive WASI std IO as Erlang messages HOT 1
- Switch to an async Rust runtime
- Seems like rust is a prerequisite? HOT 1
- Error during default engine config test and fuel consumption test HOT 4
- call_function example does not behave as expected HOT 2
- consume_fuel function example does not work as expected HOT 1
- Compatibility with Lunatic.Solutions HOT 2
- Support for dynamic linking HOT 2
- WebAssembly component support
- Unable to run go code compiled to WASM HOT 1
- Unable to run Go code compiled for WASI HOT 8
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 wasmex.