You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's a duplicated of #2352 which was closed because "It's not a bug - see the error message saying your module exited with zero.". If it's not a bug, then the sample code on this repository should be updated. I tried using ExitError, but now it crashes in another place:
diff --git a/examples/basic/add.go b/examples/basic/add.go
index 93658e9a..a4eedd70 100644
--- a/examples/basic/add.go+++ b/examples/basic/add.go@@ -11,6 +11,7 @@ import (
"github.com/tetratelabs/wazero"
"github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1"
+ "github.com/tetratelabs/wazero/sys"
)
// addWasm was generated by the following:
@@ -57,9 +58,15 @@ func main() {
add := mod.ExportedFunction("add")
results, err := add.Call(ctx, x, y)
if err != nil {
- log.Panicf("failed to call add: %v", err)+ if exitErr, ok := err.(*sys.ExitError); ok && exitErr.ExitCode() == 0 {+ // Exited with code 0. Nothing to worry about.+ } else {+ log.Panicf("failed to call add: %v", err)+ }
}
+ fmt.Printf("results is %v\n", results)+
fmt.Printf("%d + %d = %d\n", x, y, results[0])
}
$ go run . 5 8
results is []
panic: runtime error: index out of range [0] with length 0
goroutine 1 [running]:
main.main()
/home/mauriciov/kinvolk/ebpf/wazero/examples/basic/add.go:70 +0x478
exit status 2
Describe the bug
Running the basic example when compiled with tinygo v0.35.0 fails.
To Reproduce
Expected behavior
Example should run fine.
Environment (please complete the relevant information):
Additional context
It's a duplicated of #2352 which was closed because "It's not a bug - see the error message saying your module exited with zero.". If it's not a bug, then the sample code on this repository should be updated. I tried using
ExitError
, but now it crashes in another place:I bisected tinygo and it happens from tinygo-org/tinygo@ceb7891 if that's relevant somehow.
The text was updated successfully, but these errors were encountered: