Hi
I wanted to know if anyone has an idea how is it possible to override wasi function say for eg start_connect() in a go app that I have instantiated in wasmtime?
thanks
If you want to override a single function you can add functions yourself to the Linker
, but that is likely to be somewhat difficult to work around and brittle (but possible). Otherwise that level of customization probably needs support in wasmtime-wasi itself which would require a PR
okay
So I have a go application as below
package main
import (
"fmt"
"net"
"os"
)
func main() {
fmt.Println("I am from Go app")
// Make a TCP connection
conn, err := net.Dial("tcp", "example.com:80")
if err != nil {
fmt.Println("Error:", err)
os.Exit(1)
}
// Ensure conn is not nil before using it
if conn == nil {
fmt.Println("Connection is nil")
os.Exit(1)
} else {
fmt.Println("Connected to example.com:80")
conn.Close()
}
}
I haven't added the linker and all in wasmtime file. I just integrated this app to wasmtime and ran it. So only "I am from Go app"
is being printed. then after that I am getting error
Error: error while executing at wasm backtrace:
0: 0xcb6c - main!runtime.runtimePanicAt
1: 0x4920 - main!runtime.nilPanic
2: 0x2d119 - main!net.Dial
3: 0xecdb - main!main.main
4: 0xe625 - main!runtime.run$1
5: 0xe54c - main!runtime.run$1$gowrapper
6: 0x3e0 - main!tinygo_launch
7: 0xe443 - main!_start
note: using the WASMTIME_BACKTRACE_DETAILS=1
environment variable may show more debugging information
Caused by:
wasm trap: wasm unreachable
instruction executed
Any idea why is this so?
when I run this go program separately it works
That looks like the Go runtime is panicking, and alas I don't know enough about it myself to be able to know more
But when I run the go program alone it runs perfect. With wasmtime it causes error. I read somewhere tiny go compiler supports wasi preview 1 only. is that the problem?
then I compiled using standard Go compiler , it gives error connection refused.
but separately it runs perfect. Any idea?
Sorry I don't know enough about TinyGo myself to answer that
Last updated: Nov 22 2024 at 17:03 UTC