Skip to content

net/http: undocumented race condition on simultaneous calls to (*http.Server).Serve #16505

@benburkert

Description

@benburkert

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions