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/httptest: failed to listen on a port: listen tcp6 [::1]:0: socket #61452

Closed
haroon-sheikh opened this issue Jul 19, 2023 · 7 comments
Closed
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@haroon-sheikh
Copy link

haroon-sheikh commented Jul 19, 2023

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

$ go version
1.20.5 / 1.20.6

Does this issue reproduce with the latest release?

Yes

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

windows_amd64 on github actions

go env Output
$ go env
set GO111MODULE=
  set GOARCH=amd64
  set GOBIN=
  set GOCACHE=C:\Users\runneradmin\AppData\Local\go-build
  set GOENV=C:\Users\runneradmin\AppData\Roaming\go\env
  set GOEXE=.exe
  set GOEXPERIMENT=
  set GOFLAGS=
  set GOHOSTARCH=amd64
  set GOHOSTOS=windows
  set GOINSECURE=
  set GOMODCACHE=C:\Users\runneradmin\go\pkg\mod
  set GONOPROXY=
  set GONOSUMDB=
  set GOOS=windows
  set GOPATH=C:\Users\runneradmin\go
  set GOPRIVATE=
  set GOPROXY=https://proxy.golang.org,direct
  set GOROOT=C:\hostedtoolcache\windows\go\1.[20](https://github.com/getgauge/gauge/actions/runs/5603337007/jobs/10249808290#step:3:21).5\x64
  set GOSUMDB=sum.golang.org
  set GOTMPDIR=
  set GOTOOLDIR=C:\hostedtoolcache\windows\go\1.20.5\x64\pkg\tool\windows_amd64
  set GOVCS=
  set GOVERSION=go1.20.5
  set GCCGO=gccgo
  set GOAMD64=v1
  set AR=ar
  set CC=gcc
  set CXX=g++
  set CGO_ENABLED=1
  set GOMOD=D:\a\gauge\gauge\go.mod
  set GOWORK=
  set CGO_CFLAGS=-O2 -g
  set CGO_CPPFLAGS=
  set CGO_CXXFLAGS=-O2 -g
  set CGO_FFLAGS=-O2 -g
  set CGO_LDFLAGS=-O2 -g
  set PKG_CONFIG=pkg-config
  set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\RUNNER~1\AppData\Local\Temp\go-build15[27](https://github.com/getgauge/gauge/actions/runs/5603337007/jobs/10249808290#step:3:28)5[38](https://github.com/getgauge/gauge/actions/runs/5603337007/jobs/10249808290#step:3:39)[40](https://github.com/getgauge/gauge/actions/runs/5603337007/jobs/10249808290#step:3:41)7=/tmp/go-build -gno-record-gcc-switches

What did you do?

No changes to the following, but tests on github actions is now failing on windows only.

handler := func(w http.ResponseWriter, r *http.Request) {
	http.NotFound(w, r)
}

server := httptest.NewServer(http.HandlerFunc(handler))
defer server.Close()

What did you expect to see?

Tests are passing as before.

What did you see instead?

... Panic: httptest: failed to listen on a port: listen tcp6 [::1]:0: socket: The requested service provider could not be loaded or initialized. (PC=0xC0A1F2)

C:/hostedtoolcache/windows/go/1.20.5/x64/src/runtime/panic.go:884
  in gopanic
C:/hostedtoolcache/windows/go/1.20.5/x64/src/net/http/httptest/server.go:71
  in newLocalListener
C:/hostedtoolcache/windows/go/1.20.5/x64/src/net/http/httptest/server.go:119
  in NewUnstartedServer
C:/hostedtoolcache/windows/go/1.20.5/x64/src/net/http/httptest/server.go:106
  in NewServer
httpUtils_test.go:52
  in MySuite.TestDownloadFailureIfSomeHTTPError
C:/hostedtoolcache/windows/go/1.20.5/x64/src/reflect/value.go:586
  in Value.call
C:/hostedtoolcache/windows/go/1.20.5/x64/src/reflect/value.go:370
  in Value.Call
C:/hostedtoolcache/windows/go/1.20.5/x64/src/runtime/asm_amd64.s:1598
  in goexit
@haroon-sheikh haroon-sheikh changed the title httptest: failed to listen on a port: listen tcp6 [::1]:0: socket net/http/httptest: failed to listen on a port: listen tcp6 [::1]:0: socket Jul 19, 2023
@heschi
Copy link
Contributor

heschi commented Jul 20, 2023

cc @ianlancetaylor @neild

@heschi heschi added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 20, 2023
@heschi heschi added this to the Backlog milestone Jul 20, 2023
@bcmills
Copy link
Contributor

bcmills commented Jul 20, 2023

(CC @golang/windows)

@alexbrainman
Copy link
Member

@haroon-sheikh

The requested service provider could not be loaded or initialized.

This is WSAEPROVIDERFAILEDINIT Windows error message.

I googled for The requested service provider could not be loaded or initialized., and I find https://travis-ci.community/t/socket-the-requested-service-provider-could-not-be-loaded-or-initialized/1127 which points me to #25210 .

I suspect you are doing something similar to what happens in #25210 .

Alex

@haroon-sheikh
Copy link
Author

Thanks @alexbrainman for getting back. A couple of our unittests are calling os.Clearenv(). I wonder if it's clearing out SYSTEMROOT variable as well.

@bcmills
Copy link
Contributor

bcmills commented Jul 24, 2023

I wonder if it's clearing out SYSTEMROOT variable as well.

os.Clearenv is defined to delete all environment variables, so if that is not the case it's arguably a bug. 😅

@bcmills bcmills added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jul 24, 2023
@alexbrainman
Copy link
Member

A couple of our unittests are calling os.Clearenv(). I wonder if it's clearing out SYSTEMROOT variable as well.

I would avoid calling os.Clearenv() on Windows. Different computers have different software / drivers installed on them. So environment variables used on each system will be different too.

Alex

@haroon-sheikh
Copy link
Author

haroon-sheikh commented Jul 25, 2023

I have removed a couple of Clearenv() calls from unittests that was causing the failures. Thanks for your help.

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

No branches or pull requests

4 participants