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

net/http: wasi deadlock #65928

Closed
arejula27 opened this issue Feb 24, 2024 · 11 comments
Closed

net/http: wasi deadlock #65928

arejula27 opened this issue Feb 24, 2024 · 11 comments
Labels
arch-wasm WebAssembly issues NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@arejula27
Copy link

Go version

go version go1.21.7 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/arejula27/.cache/go-build'
GOENV='/home/arejula27/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/arejula27/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/arejula27/go'
GOPRIVATE=''
GOPROXY='direct'
GOROOT='/usr/lib/golang'
GOSUMDB='off'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/lib/golang/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.7'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/arejula27/workspaces/go-lab/echo/go.mod'
GOWORK='/home/arejula27/workspaces/go-lab/go.work'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2105186211=/tmp/go-build -gno-record-gcc-switches'

What did you do?

I compiled simple web servers using GOOS=wasip1 GOARCH=wasm and try to run it.
image

What did you see happen?

The program crash because it detects a deadclock

What did you expect to see?

To run correctly

@panjf2000
Copy link
Member

Did you run this example in the expected environment: GOOS=wasip1 GOARCH=wasm?

@panjf2000
Copy link
Member

And it reproduces constantly?

@panjf2000 panjf2000 added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. arch-wasm WebAssembly issues labels Feb 25, 2024
@AndrusGerman
Copy link

Exactly the same problem in Windows.

@odeke-em
Copy link
Member

Kindly cc-ing @neelance

@mauri870
Copy link
Member

I believe the wasip1 port does not support creating sockets, so you can't really have http servers with it.

An excerpt from the WASI blog post:

A notable missing feature in the wasip1 API is a full implementation of network sockets. wasip1 only defines functions that operate on already opened sockets, making it impossible to support some of the most popular features of the Go standard library, such as HTTP servers. Hosts like Wasmer and WasmEdge implement extensions to the wasip1 API, allowing the opening of network sockets. While these extensions are not implemented by the Go compiler, there exists a third party library, github.com/stealthrocket/net, which uses go:wasmimport to allow the use of net.Dial and net.Listen on supported Wasm hosts. This enables the creation of net/http servers and other network related functionality when using this package.

@bcmills
Copy link
Contributor

bcmills commented Feb 26, 2024

In particular, the wasip1/wasm port uses a fake network stack that can only accept other connections from the same process. If there are no other goroutines in the same process that can dial a connection, then the program is indeed deadlocked.

@bcmills
Copy link
Contributor

bcmills commented Feb 26, 2024

@AndrusGerman

Exactly the same problem in Windows.

Go's Windows networking stack is pretty much completely separate from the fake wasm net stack. If you are seeing a problem on Windows, please file a new issue and fill out the issue template.

@Malix-off
Copy link

Malix-off commented Feb 26, 2024

Potentially fixable by #65333

See https://github.com/WebAssembly/WASI/tree/main/preview2#wasi-preview-2-contents

And specifically

@arejula27
Copy link
Author

arejula27 commented Feb 26, 2024

Did you run this example in the expected environment: GOOS=wasip1 GOARCH=wasm?

Yes, i compiled It with this GOOS=wasip1 GOARCH=wasm

@seankhliao
Copy link
Member

Closing this as sockets aren't supported for wasi

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Mar 31, 2024
@Malix-off
Copy link

sockets aren't supported for wasi

yet* indeed;
Better to close as not planned for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly issues NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

8 participants