Closed loredanacirstea closed 1 year ago
I was following the docs from https://wasmedge.org/book/en/sdk/go/ref.html#ast-module:
loader := wasmedge.NewLoader() ast, err := loader.LoadBuffer(wasmbuffer) if err != nil { fmt.Println("Load WASM from file FAILED:", err.Error()) } imports := ast.ListImports() for _, mimport := range imports { fmt.Println("Import:", mimport.GetModuleName(), mimport.GetExternalName()) } // List the exports. exports := ast.ListExports() for _, mexport := range exports { fmt.Println("Export:", mexport.GetExternalName()) } ast.Release() loader.Release()
The panic comes from https://github.com/second-state/WasmEdge-go/blob/746946a0f856f0ddb6523fb3c9780d19493cb56a/wasmedge/ast.go#L63, respectively https://github.com/second-state/WasmEdge-go/blob/746946a0f856f0ddb6523fb3c9780d19493cb56a/wasmedge/ast.go#L83
When initializing imptype = make([]*ImportType, uint(ltypes)), imptype gets initialized with nil. So the solution is to initialize imptype[i] = &ImportType{} before line 63.
imptype = make([]*ImportType, uint(ltypes))
imptype
nil
imptype[i] = &ImportType{}
From the debugger:
I was following the docs from https://wasmedge.org/book/en/sdk/go/ref.html#ast-module:
The panic comes from https://github.com/second-state/WasmEdge-go/blob/746946a0f856f0ddb6523fb3c9780d19493cb56a/wasmedge/ast.go#L63, respectively https://github.com/second-state/WasmEdge-go/blob/746946a0f856f0ddb6523fb3c9780d19493cb56a/wasmedge/ast.go#L83
When initializing
imptype = make([]*ImportType, uint(ltypes))
,imptype
gets initialized withnil
. So the solution is to initializeimptype[i] = &ImportType{}
before line 63.From the debugger: