Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(wamr): add wasm-mico-runtime shim implementation #716

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

Mossaka
Copy link
Member

@Mossaka Mossaka commented Nov 3, 2024

Follow up on the work done by #508 and #642. The runtime execution "thread signal env initialized failed" error was resolved by the upstream Wamr SDK and thus I used the latest sdk to re-build the wamr shim.

Now it actually worked!

sudo ctr run  --net-host --rm --runtime=io.containerd.wamr.v1 ghcr.io/containerd/runwasi/wasi-demo-app:latest testwasm /wasi-demo-app.wasm echo "hi"
hi
exiting

TODO

Maciej and others added 8 commits November 3, 2024 22:01
…error

upstream to the official wamr SDK solves this issue

Signed-off-by: jiaxiao zhou <[email protected]>
I believe there are more work to be done to parse the runtimeError
to appropriate exit code.

failures:
    wamr_tests::test_custom_entrypoint
    wamr_tests::test_exit_code
    wamr_tests::test_hello_world_oci
    wamr_tests::test_seccomp
    wamr_tests::test_unreachable

Signed-off-by: jiaxiao zhou <[email protected]>
Comment on lines 89 to 92
.or_else(|err| {
log::error!("Error: {:?}", err);
Err(err)
})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should parse the RuntimeError to appropriate exit code. Any thoughts on this one, @lum1n0us?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding that, I just noticed that WAMR only uses error strings to convey information if something goes wrong during the execution of a Wasm function. So, if it's okay, can we continue to display the error string in the log and use a simple -1 and 0 to indicate failure and success, respectively?

Copy link
Member Author

@Mossaka Mossaka Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, how can I get exit code 42 from running this wasm module?

(module
    ;; Import the required proc_exit WASI function which terminates the program with an exit code.
    ;; The function signature for proc_exit is:
    ;; (exit_code: i32) -> !
    (import "wasi_snapshot_preview1" "proc_exit" (func $proc_exit (param i32)))
    (memory 1)
    (export "memory" (memory 0))
    (func $main (export "_start")
        (call $proc_exit (i32.const 42))
        unreachable
    )
)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a fix for this situation. Please have a look.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged

@Mossaka
Copy link
Member Author

Mossaka commented Nov 5, 2024

@lum1n0us do you know why the entrypoint_test failed?

thread 'wamr_tests::test_custom_entrypoint' panicked at crates/containerd-shim-wamr/src/tests.rs:58:5:
assertion `left == right` failed
  left: "hello world\n[00:08:01:896 - 7FA1CA910640]: warning: a module with WASI apis should be either a command or a reactor\n"
 right: "hello world\n"

@Mossaka
Copy link
Member Author

Mossaka commented Nov 5, 2024

@lum1n0us
Copy link

lum1n0us commented Nov 5, 2024

Yes, that's because WAMR enforces a strict application ABI check. Every wasm32-wasi .wasm should be classified as either a command or a reactor.

For your case,

  • either patch the case as a command, for example. Add a function like (func $start (export "_start"))
  • or WAMR turns off the WARNING messages by setting a higher log level.

@lum1n0us
Copy link

So, which option?

@Mossaka
Copy link
Member Author

Mossaka commented Nov 13, 2024

I disabled that test for now and I don't think we need to pass it to get this PR merged. Let me fix the linting issue.

if the target is windows, do not import the APIs
changed the compiler_error to panic!

Signed-off-by: jiaxiao zhou <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants