second-state / WasmEdge-go

The GO language SDK and API for WasmEdge
https://www.secondstate.io/articles/extend-golang-app-with-webassembly-rust/
Apache License 2.0
107 stars 16 forks source link

Validate report 'magic header not detected' #14

Closed DarumaDocker closed 2 years ago

DarumaDocker commented 2 years ago

If I load wasm using vm.LoadWasmBuffer, then the vm.Validate() will result with an error: 'magic header not detected'

hydai commented 2 years ago

Could you also provide the wasm file?

DarumaDocker commented 2 years ago

https://github.com/second-state/WasmEdge-go-examples/tree/master/go_ExternRef

Only change

vm.LoadWasmFile(os.Args[1])

to

b, er := ioutil.ReadFile(os.Args[1])
  if er != nil {
    log.Fatal(er)
  }
  er = vm.LoadWasmBuffer(b)
  if er != nil {
    log.Fatal(er)
  }

You will get the error.

q82419 commented 2 years ago

This is fixed in the v0.9.0-rc1.