wagon icon indicating copy to clipboard operation
wagon copied to clipboard

validate: could not validate a simple program

Open sbinet opened this issue 7 years ago • 9 comments

trying to validate a simple program:

package main

func main() {
	println("hello")
	println("1+3=", myadd(1, 3))
}

func myadd(i, j int) int {
	return i + j
}

compiled with GOOS=js GOARCH=wasm and the gc compiler from neelance go-wasm-wip, I get:

$> wasm-run -verify-module ./a.wasm
wasm-run: could not verify module: error while validating function 686 at offset 64: invalid type, got: i32, wanted: i64

running WebAssembly.validate (from my chromium browser) did not raise anything.

@vibhavp any idea?

sbinet avatar Nov 28 '17 15:11 sbinet

Could you give me the .wasm file produced by the compiler?

vibhavp avatar Nov 28 '17 15:11 vibhavp

it's there: https://cern.ch/binet/wasm/a.wasm

sbinet avatar Nov 28 '17 16:11 sbinet

From the wasm Go fork, I observed that node uses this file to define some runtime functions: https://github.com/neelance/go/blob/wasm-wip/misc/wasm/wasm_exec.js

With wagon, they aren't getting defined, which is what might be causing the issue. I'll take a look at this anyway.

vibhavp avatar Nov 29 '17 03:11 vibhavp

perhaps needs go-interpreter/wagon#40

sbinet avatar Dec 05 '17 16:12 sbinet

ping @vibhavp ?

Robert's work (bringing GOARCH=wasm to the official gc toolchain) is starting to percolate. it would be great to have this working for Go-1.11.x :)

sbinet avatar Apr 03 '18 13:04 sbinet

Sorry for forgetting about this. I took another stab at my PR today, and was able to narrow it down to the value of NewStack.StackTopDiff somehow changing while compiling Else blocks. I'll further investigate tomorrow, and try coming up with a fix soon.

On Tue 3 Apr, 2018, 6:46 PM Sebastien Binet, [email protected] wrote:

ping @vibhavp https://github.com/vibhavp ?

Robert's work (bringing GOARCH=wasm to the official gc toolchain) is starting to percolate. it would be great to have this working for Go-1.11.x :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/go-interpreter/wagon/issues/36#issuecomment-378246218, or mute the thread https://github.com/notifications/unsubscribe-auth/ACCymKjkuXH-Mv7RhgYEoWLF1gM9Ym34ks5tk3Y-gaJpZM4Qtahj .

vibhavp avatar Apr 03 '18 20:04 vibhavp

ping @vibhavp ? :)

sbinet avatar Jun 08 '18 09:06 sbinet

I have the same problem.

hunjixin avatar Jan 12 '19 10:01 hunjixin

I took another stab at my PR today, and was able to narrow it down to the value of NewStack.StackTopDiff somehow changing while compiling Else blocks.

I don't see any Else blocks in the a.wasm file linked above, but if it is an issue around Else blocks then it might be related to https://github.com/go-interpreter/wagon/pull/104.

cdetrio avatar Feb 20 '19 13:02 cdetrio