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: undocumented race condition on simultaneous calls to (*http.Server).Serve #16505

Closed
benburkert opened this issue Jul 26, 2016 · 4 comments

Comments

@benburkert
Copy link
Contributor

Please answer these questions before submitting your issue. Thanks!

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

go version go1.7rc3 darwin/amd64

  1. What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/benburkert"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.7rc3/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.7rc3/libexec/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/jl/n78jzg3j6nb8nzbn1vvpg9xc0000gn/T/go-build053329638=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
  1. What did you do?
    If possible, provide a recipe for reproducing the error.
    A complete runnable program is good.
    A link on play.golang.org is best.

run this with the race detector: https://play.golang.org/p/9WopZBGsFq

  1. What did you expect to see?

I think the documentation should mention that it is not safe to call Serve with multiple listeners. I have seen this pattern repeated many times for the http & https listeners.

  1. What did you see instead?

Data race warning: https://gist.github.com/benburkert/4eb8e7e4acb72984f7568f4e1fdf1847

@nhooyr
Copy link
Contributor

nhooyr commented Jul 26, 2016

This was introduced by http2.

http.Server.http2ConfigureServer can write to s.TLSConfig at the same time as http.Server.shouldConfigureHTTP2ForServe can read it.

@bradfitz
Copy link
Contributor

This was introduced by http2.

No, it was introduced in b5f0aff which was one month ago. Go 1.6 included http2 and doesn't exhibit this race.

@bradfitz bradfitz added this to the Go1.7Maybe milestone Jul 26, 2016
@bradfitz bradfitz self-assigned this Jul 26, 2016
@nhooyr
Copy link
Contributor

nhooyr commented Jul 26, 2016

Oh, my bad, sorry.

@gopherbot
Copy link
Contributor

CL https://golang.org/cl/25280 mentions this issue.

@golang golang locked and limited conversation to collaborators Jul 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants