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: panic dialing udp address on node/wasm #60012

Closed
seankhliao opened this issue May 5, 2023 · 4 comments
Closed

net: panic dialing udp address on node/wasm #60012

seankhliao opened this issue May 5, 2023 · 4 comments
Labels
arch-wasm WebAssembly issues NeedsFix The path to resolution is known, but the work has not been done. OS-JS
Milestone

Comments

@seankhliao
Copy link
Member

What version of Go are you using (go version)?

$ go version
go version devel go1.21-10ad6c91de1 Fri May 5 19:53:39 2023 +0000 linux/amd64

Does this issue reproduce with the latest release?

no (1.20.4)

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/arccy/.cache/go-build'
GOENV='/home/arccy/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS='-trimpath "-ldflags=-s -w"'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/arccy/.data/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/arccy/.data/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/arccy/sdk/gotip'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLDIR='/home/arccy/sdk/gotip/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='devel go1.21-10ad6c91de1 Fri May 5 19:53:39 2023 +0000'
GCCGO='gccgo'
GOAMD64='v3'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='0'
GOMOD='/home/arccy/tmp/testrepo0180/go.mod'
GOWORK=''
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 -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build162874202=/tmp/go-build -gno-record-gcc-switches'
21:16:55 ~/tmp/test

What did you do?

package main

import (
	"log"
	"net"
)

func main() {
	_, err := net.Dial("udp", "127.0.0.1:1234")
	if err != nil {
		log.Fatalln(err)
	}
}
main » node --version
v19.9.0

21:18:03 ~/tmp/testrepo0180 0:00:00
main » GOOS=js GOARCH=wasm go build -o main.wasm main.go     

21:18:07 ~/tmp/testrepo0180 0:00:00
main » node ~/sdk/gotip/misc/wasm/wasm_exec_node.js main.wasm
panic: interface conversion: net.Addr is *net.UDPAddr, not *net.TCPAddr

goroutine 1 [running]:
net.socket({0x50110, 0x16ef60}, {0x2f2da, 0x3}, 0x2, 0x2, 0x0, 0x0, {0x50398, 0x0}, ...)
	net/net_fake.go:92 +0x59
net.internetSocket({0x50110, 0x16ef60}, {0x2f2da, 0x3}, {0x50398, 0x0}, {0x50398, 0x143a420}, 0x2, 0x0, ...)
	net/ipsock_posix.go:142 +0x3
net.(*sysDialer).dialUDP(0x14561e0, {0x50110, 0x16ef60}, 0x0, 0x143a420)
	net/udpsock_posix.go:212 +0x7
net.(*sysDialer).dialSingle(0x14561e0, {0x50110, 0x16ef60}, {0x4ff80, 0x143a420})
	net/dial.go:643 +0x2c
net.(*sysDialer).dialSerial(0x14561e0, {0x50110, 0x16ef60}, {0x140e0c0, 0x1, 0x1})
	net/dial.go:604 +0x1c
net.(*sysDialer).dialParallel(0x14561e0, {0x50110, 0x16ef60}, {0x140e0c0, 0x1, 0x1}, {0x0, 0x0, 0x0})
	net/dial.go:505 +0x28
net.(*Dialer).DialContext(0x144ae78, {0x50110, 0x16ef60}, {0x2f2da, 0x3}, {0x30a9e, 0xe})
	net/dial.go:496 +0x64
net.(*Dialer).Dial(...)
	net/dial.go:423
net.Dial({0x2f2da, 0x3}, {0x30a9e, 0xe})
	net/dial.go:390 +0x8
main.main()
	./main.go:9 +0x2

What did you expect to see?

an error like "Protocol not available"

What did you see instead?

panic asserting a TCP address

cc @golang/wasm

@seankhliao seankhliao added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. arch-wasm WebAssembly issues OS-JS labels May 5, 2023
@bcmills
Copy link
Contributor

bcmills commented May 8, 2023

I wonder — does that also apply to GOOS=wasip1? I think they use the same net stack.

Also in the category of “net on wasm is weird and buggy”:

@seankhliao
Copy link
Member Author

I think so

//go:build (js && wasm) || wasip1

@johanbrandhorst
Copy link
Member

@gopherbot
Copy link

Change https://go.dev/cl/502315 mentions this issue: net: fix panic when calling net.Listen or net.Dial on wasip1

@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jun 14, 2023
@dmitshur dmitshur added this to the Go1.21 milestone Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly issues NeedsFix The path to resolution is known, but the work has not been done. OS-JS
Projects
None yet
Development

No branches or pull requests

5 participants