wasmerio / wasmer-go

🐹🕸️ WebAssembly runtime for Go
https://pkg.go.dev/github.com/wasmerio/wasmer-go
MIT License
2.84k stars 161 forks source link

No error print? #386

Open orangeC23 opened 1 year ago

orangeC23 commented 1 year ago

Summary

Related to https://github.com/wasmerio/wasmer-python/issues/713 The go file is:

package main

import (
    "fmt"
    "github.com/wasmerio/wasmer-go/wasmer"
    "io/ioutil"
)

func main() {
    wasmBytes, _ := ioutil.ReadFile("./tmp.wasm")

    engine := wasmer.NewEngine()
    store := wasmer.NewStore(engine)

    // Compiles the module
    module, err := wasmer.NewModule(store, wasmBytes)

    if err != nil {
        fmt.Println("Failed to compile module:", err)
    }

    importObject := wasmer.NewImportObject()
    instance, err := wasmer.NewInstance(module, importObject)

    if err != nil {
        panic(fmt.Sprintln("Failed to instantiate the module:", err))
    }
    start, err := instance.Exports.GetWasiStartFunction()

    start()

}

Additional details

wasmer go also print nothing, did not report the error as wasmer does. wasmer go print: panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4099a19]

goroutine 1 [running]: main.main() tmp.go:31 +0x119 exit status 2