Giter Site home page Giter Site logo

Comments (4)

tessi avatar tessi commented on May 31, 2024

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.

lok0613 avatar lok0613 commented on May 31, 2024

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.

tessi avatar tessi commented on May 31, 2024

@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.

tessi avatar tessi commented on May 31, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.