os: GOOS=wasip1 GOARCH=wasm
the ReadFile
function gives -1
as the rootFd
to path_open
causing Bad file number
error
#63466
Labels
arch-wasm
WebAssembly issues
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, the same issue happens with the
master
branch binary produced byall.bash
Commit 2744155
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
The whole project is here https://github.com/HarikrishnanBalagopal/test-wasi-fs-browser
The JS code is here https://github.com/HarikrishnanBalagopal/test-wasi-fs-browser/blob/d105e396d3d2c00bbe37d823279978b030a72a00/public/src/index.js
What did you expect to see?
Compiling with TinyGo
CGO_ENABLED=0 tinygo build -o bin/test.wasm -target=wasi .
and running in the browser using this WASI virtual filesystem library https://github.com/bjorn3/browser_wasi_shim I get this outputexpected a similar output with the official Go compiler.
What did you see instead?
Compiling with the official Go compiler
CGO_ENABLED=0 GOOS=wasip1 GOARCH=wasm go build -o bin/test.wasm .
and keeping everything else exactly the same I get this errorContext
Doing some debugging by proxying the WASI imports in the browser, I see that
-1
is being passed as the file description to thepath_open
host function https://wasix.org/docs/api-reference/wasi/path_openFor comparison TinyGo provides
3
as the file descriptor(0 stdin, 1 stdout, 2 stderr)
go/src/syscall/fs_wasip1.go
Lines 555 to 556 in 2744155
go/src/syscall/fs_wasip1.go
Lines 492 to 493 in 2744155
Related #60732 (comment)
The text was updated successfully, but these errors were encountered: