Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation failure on 32-bit systems #199

Open
BugFreeSoftware opened this issue Oct 26, 2023 · 3 comments
Open

Compilation failure on 32-bit systems #199

BugFreeSoftware opened this issue Oct 26, 2023 · 3 comments

Comments

@BugFreeSoftware
Copy link

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.

@alexcrichton
Copy link
Member

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?

@BugFreeSoftware
Copy link
Author

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
Copy link
Contributor

guregu commented Oct 31, 2023

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

alexcrichton pushed a commit that referenced this issue Oct 31, 2023
* use unsafe.Slice in Memory.UnsafeData (#199)

* bump bazel build's Go to 1.21.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants