bytecodealliance/wasmtime-go

Compilation failure on 32-bit systems

BugFreeSoftware opened this issue · 3 comments

In memory.go:

func (mem *Memory) UnsafeData(store Storelike) []byte {
	// see https://github.com/golang/go/wiki/cgo#turning-c-arrays-into-go-slices
	const MaxLen = 1 << 32
	length := mem.DataSize(store)
	if length >= MaxLen {
		panic("memory is too big")
	}
	return (*[MaxLen]byte)(mem.Data(store))[:length:length]
}

The 1 << 32 results in an overflow because uintptr type is 32bit on 32bit systems.
I suggest replacing it with 0xffffffff instead. That should remove the compilation error.

Thanks for the report! While this should be fixed, I'll also note that currently Wasmtime does not have support for any 32-bit systems. Which platform would you like to target?

We have a system that uses WasmTime. One of our community members was trying to run it on Android.
He was trying to run the test suite that comes with the client software, and I just realized that this test suite pulls in our entire system, including WasmTime. That is a bug on our end. I should fix the test suite to only use the client code and have it test against a separately running test instance of our system.
Anyway, it's a potential bug and simple to fix.

guregu commented

Just made a PR that should fix this: #200. It uses a new-ish API that sidesteps the issue.