PhilippGackstatter / wow

A WebAssembly container runtime for the Apache OpenWhisk serverless platform
21 stars 6 forks source link

Error on precompiling "add" #2

Closed nerdola-de-cartola closed 1 year ago

nerdola-de-cartola commented 1 year ago

I got an error while trying to follow the tutorial on readme.md

COMMAND: cargo run --manifest-path ./ow-wasmtime-precompiler/Cargo.toml --release --bin wasmtime ./target/wasm32-wasi/release/examples/add.wasm

ERROR:

Finished release [optimized] target(s) in 0.11s
     Running `target/release/wasmtime ./target/wasm32-wasi/release/examples/add.wasm`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: expected at least one module field
     --> ./target/wasm32-wasi/release/examples/add.wasm:1:1
      |
    1 |
      | ^', ow-wasmtime-precompiler/src/bin/wasmtime.rs:11:72
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Can you please help me out?

nerdola-de-cartola commented 1 year ago
stack backtrace:
   0: rust_begin_unwind
             at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/panicking.rs:65:14
   2: core::result::unwrap_failed
             at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/result.rs:1791:5
   3: wasmtime::precompile_wasmtime
   4: wasmtime::main
full stack backtrace:
   0:     0x5631c2d55253 - std::backtrace_rs::backtrace::libunwind::trace::h1d00f3fcf4cb5ac4
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x5631c2d55253 - std::backtrace_rs::backtrace::trace_unsynchronized::h920a6ff332484ee2
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x5631c2d55253 - std::sys_common::backtrace::_print_fmt::hd7323920c925af6d
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x5631c2d55253 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3155a8c966b4beb5
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x5631c2bf6b3e - core::fmt::write::h062c617411b691df
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/fmt/mod.rs:1209:17
   5:     0x5631c2d34064 - std::io::Write::write_fmt::hb61fdf1275c61e1c
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/io/mod.rs:1682:15
   6:     0x5631c2d563bf - std::sys_common::backtrace::_print::hd1b4d9664ab500e0
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x5631c2d563bf - std::sys_common::backtrace::print::hca896ae22beb06cb
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x5631c2d55fbf - std::panicking::default_hook::{{closure}}::h0b5eeed5cf36ab5f
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/panicking.rs:267:22
   9:     0x5631c2d57058 - std::panicking::default_hook::h8932b573145a321b
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/panicking.rs:286:9
  10:     0x5631c2d57058 - std::panicking::rust_panic_with_hook::h4b1447a24e3e94f8
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/panicking.rs:688:13
  11:     0x5631c2d56b22 - std::panicking::begin_panic_handler::{{closure}}::h8701da9995a3820c
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/panicking.rs:579:13
  12:     0x5631c2d56a8c - std::sys_common::backtrace::__rust_end_short_backtrace::hb696c5ed02a01598
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/sys_common/backtrace.rs:137:18
  13:     0x5631c2d56a61 - rust_begin_unwind
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/panicking.rs:575:5
  14:     0x5631c2b84412 - core::panicking::panic_fmt::h8aa706a976963c88
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/panicking.rs:65:14
  15:     0x5631c2b846b2 - core::result::unwrap_failed::h065c02f906ca4578
                               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/result.rs:1791:5
  16:     0x5631c2d935a9 - wasmtime::precompile_wasmtime::he00bfef06bad4158
  17:     0x5631c2d95b74 - wasmtime::main::hebd6f691c9dea128
  18:     0x5631c2d97a63 - std::sys_common::backtrace::__rust_begin_short_backtrace::h8a9d6db4063bd5b1
  19:     0x5631c2d93eb7 - main
  20:     0x7fb3b340f083 - __libc_start_main
                               at /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
  21:     0x5631c2baf21e - _start
  22:                0x0 - <unknown>
nerdola-de-cartola commented 1 year ago

As far as I know step 3 is necessary to generate the add-wasmtime.zip file used in step 7. Perhaps we can create this file some other way to avoid the error?

PhilippGackstatter commented 1 year ago

Hi @nerdola-de-cartola, thanks for reaching out! I'm busy until next week, but will take a look at it then.

nerdola-de-cartola commented 1 year ago

Thanks for your help, please let me know if you need any extra information

PhilippGackstatter commented 1 year ago

Apologies for the late response.

I cannot reproduce the error on my machine (Kubuntu 22.04, Rust 1.70). I have not tested this setup on Windows or macOS, so if you are on those platforms that might be a potential cause, but I don't really think that's the issue. Make sure to use the Cargo.lock file in the repo.

Otherwise, can you provide more information on your platform and Rust/Cargo setup?

nerdola-de-cartola commented 1 year ago

Well actually the problem was fixed after I moved to the same version of Rust. But I'm still not able to get the example running correctly. I'm getting the result "The action failed during initialization."

Here is the complete response after wsk action invoke

{
    "activationId": "865d0a5f1fb946e69d0a5f1fb926e6ef",
    "annotations": [
        {
            "key": "path",
            "value": "guest/add"
        },
        {
            "key": "waitTime",
            "value": 31
        },
        {
            "key": "kind",
            "value": "wasm:0.1"
        },
        {
            "key": "timeout",
            "value": false
        },
        {
            "key": "limits",
            "value": {
                "concurrency": 1,
                "logs": 10,
                "memory": 256,
                "timeout": 60000
            }
        },
        {
            "key": "initTime",
            "value": 28
        }
    ],
    "duration": 28,
    "end": 1687977626757,
    "logs": [],
    "name": "add",
    "namespace": "guest",
    "publish": false,
    "response": {
        "result": {
            "error": "The action failed during initialization."
        },
        "size": 0,
        "status": "action developer error",
        "success": false
    },
    "start": 1687977626729,
    "subject": "guest",
    "version": "0.0.1"
}
PhilippGackstatter commented 1 year ago

When you run ./target/release/executor in another terminal, what is the output there? Does it show a log like this?

/init add
Initializing container with id db39271f-fd0f-4782-92ca-30a2b508df62
...

I just followed the tutorial again end-to-end and for me it's still working with the latest Rust version.

nerdola-de-cartola commented 1 year ago

Man, I finally manage to correctly execute the project

Your last reply makes me think that maybe the problem was my docker version. Because I am running docker on WSL2 (virtual machine for windows) there are a few ways of running docker on this environment. So I completely reinstalled my docker and start the tutorial from scratch. Now everything works fine.

Thanks for your help. Maybe I will be able to extend the research on wasm

PhilippGackstatter commented 1 year ago

Glad to hear you were able to run the project! I'm always interested in hearing about research related to or built on top of this project, so feel free to let me know if that happens!