-
Notifications
You must be signed in to change notification settings - Fork 951
runtime (wasi): 64-bit integers require 8 byte alignment #2010
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
Comments
Actually, nevermind. It does in fact need 8-byte alignment. |
Note that this also does replicate under the conservative collector with another 4-byte-aligned address. |
Reference: https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#-timestamp-u64 indicates that the alignment of a timestamp is 8 bytes. |
Huh, interesting. I can reproduce this with this simpler code: package main
func main() {
var nano uint64
println(&nano)
} |
Er, yeah I see that printing a value with 4-byte alignment. I don't think that most of the code expects anything to need higher alignment. The thing that surprised me was the crash. |
Here is an ugly workaround: diff --git a/src/runtime/gc_conservative.go b/src/runtime/gc_conservative.go
index e9682592..b6d18455 100644
--- a/src/runtime/gc_conservative.go
+++ b/src/runtime/gc_conservative.go
@@ -228,6 +228,7 @@ func setHeapEnd(newHeapEnd uintptr) {
// This function can be called again when the heap size increases. The caller is
// responsible for copying the metadata to the new location.
func calculateHeapAddresses() {
+ heapStart = (heapStart + 7) &^ 7
totalSize := heapEnd - heapStart
// Allocate some memory to keep 2 bits of information about every block. Related (possibly even a duplicate): #2009 |
While working on asyncify support, I ran into a crash where
wasmtime
failed to store the timestamp. Interestingly, my debug code also caused it to reproduce on thedev
branch.This bug can be reproduced by attempting to print the address of the timestamp before passing it to
clock_time_get
:The address (
0x0001064c
) appears to be 4-byte aligned. I don't think that is incorrect on 32-bit wasm?However it breaks wasmtime:
Not entirely sure what is wrong yet.
The text was updated successfully, but these errors were encountered: