Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

WASIP2: Output truncated/repeats after 4096 bytes #5012

Open
Assignees
Labels
wasmWebAssembly
@ErikFrankling

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

wasmWebAssembly

Type

No type

Projects

No projects

Milestone

No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /