-
Notifications
You must be signed in to change notification settings - Fork 989
Open
Labels
wasmWebAssemblyWebAssembly
Description
This example code:
package main
import "fmt"
func main() {
start := "start"
var a [4099]byte
for j := 0; j < len(a); j++ {
if j%3 == 0 {
a[j] = 'A'
} else if j%3 == 1 {
a[j] = 'B'
} else if j%3 == 2 {
a[j] = 'C'
}
}
copy(a[:], start)
fmt.Printf("%s", a)
fmt.Println()
}
Run with this:
tinygo build -target=wasip2 -o test.wasm main.go
wasmtime run test.wasm
Gives an output that starts repeating after 4096 bytes
But running normally:
tinygo run .
# or
go run .
Gives the expected output.
I think this is the offending code (have not had much time to look into it yet):
https://github.com/tinygo-org/tinygo/blob/3869f76887feef6c444308e7e1531b7cac1bbd10/src/runtime/runtime_tinygowasmp2.go#L24C1-L32C2
So the issue would be using this function incorrectly:
https://github.com/WebAssembly/wasi-io/blob/73222408bd3de90c8a9144c9ece02bb606c834f6/wit/streams.wit#L154C1-L167C38
I am new to WASM so any pointers are welcome :)
Metadata
Metadata
Assignees
Labels
wasmWebAssemblyWebAssembly