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: possible leaky goroutine #15650

Closed
gyuho opened this issue May 11, 2016 · 4 comments
Closed

net/http/httptest: possible leaky goroutine #15650

gyuho opened this issue May 11, 2016 · 4 comments

Comments

@gyuho
Copy link
Contributor

gyuho commented May 11, 2016

I am still investigating this issue, but I would like to get some help to debug it.

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

go 1.6.1

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

Semaphore CI with Ubuntu 14.04 LTS

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/runner/workspace/src/github.com/coreos/etcd/gopath"
GORACE=""
GOROOT="/usr/local/golang/1.6.1/go"
GOTOOLDIR="/usr/local/golang/1.6.1/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

What did you do?

This was first reported at etcd-io/etcd#5275. I've been trying to reproduce in my local machine, but haven't been able to for the last two days. It often happens in the slow CI environment with go test -v -race -cpu 4 -run=ExampleLease_keepAliveOnce command.

What did you expect to see?

No race condition.

What did you see instead?

Too many goroutines running after all test(s).
1 instances of:
internal/race.Enable()
    /usr/local/golang/1.6.1/go/src/internal/race/race.go:32
sync.(*WaitGroup).Add(...)
    /usr/local/golang/1.6.1/go/src/sync/waitgroup.go:92 +0x27d
sync.(*WaitGroup).Done(...)
    /usr/local/golang/1.6.1/go/src/sync/waitgroup.go:96 +0x38
net/http/httptest.(*Server).forgetConn(...)
    /usr/local/golang/1.6.1/go/src/net/http/httptest/server.go:329 +0xe7
net/http/httptest.(*Server).wrap.func1(...)
    /usr/local/golang/1.6.1/go/src/net/http/httptest/server.go:283 +0x654
net/http.(*conn).setState(...)
    /usr/local/golang/1.6.1/go/src/net/http/server.go:1371 +0x7d
net/http.(*conn).serve.func1(...)
    /usr/local/golang/1.6.1/go/src/net/http/server.go:1394 +0x35a
net/http.(*conn).serve(...)
    /usr/local/golang/1.6.1/go/src/net/http/server.go:1452 +0x11ff
created by net/http.(*Server).Serve
    /usr/local/golang/1.6.1/go/src/net/http/server.go:2137 +0x4d2
1 instances of:
net.runtime_pollWait(...)
    /usr/local/golang/1.6.1/go/src/runtime/netpoll.go:160 +0x63
net.(*pollDesc).Wait(...)
    /usr/local/golang/1.6.1/go/src/net/fd_poll_runtime.go:73 +0x56
net.(*pollDesc).WaitRead(...)
    /usr/local/golang/1.6.1/go/src/net/fd_poll_runtime.go:78 +0x44
net.(*netFD).Read(...)
    /usr/local/golang/1.6.1/go/src/net/fd_unix.go:250 +0x27b
net.(*conn).Read(...)
    /usr/local/golang/1.6.1/go/src/net/net.go:172 +0x121
net.(*TCPConn).Read(...)
    <autogenerated>:68 +0x7d
github.com/coreos/etcd/pkg/transport.timeoutConn.Read(...)
    /home/runner/workspace/src/github.com/coreos/etcd/gopath/src/github.com/coreos/etcd/pkg/transport/timeout_conn.go:43 +0x1d6
github.com/coreos/etcd/pkg/transport.(*timeoutConn).Read(...)
    <autogenerated>:42 +0xf0
net/http.noteEOFReader.Read(...)
    /usr/local/golang/1.6.1/go/src/net/http/transport.go:1683 +0x75
net/http.(*noteEOFReader).Read(...)
    <autogenerated>:284 +0xf8
bufio.(*Reader).fill(...)
    /usr/local/golang/1.6.1/go/src/bufio/bufio.go:97 +0x365
bufio.(*Reader).Peek(...)
    /usr/local/golang/1.6.1/go/src/bufio/bufio.go:132 +0x187
net/http.(*persistConn).readLoop(...)
    /usr/local/golang/1.6.1/go/src/net/http/transport.go:1069 +0x223
created by net/http.(*Transport).dialConn
    /usr/local/golang/1.6.1/go/src/net/http/transport.go:853 +0x16f0
1 instances of:
net/http.(*persistConn).writeLoop(...)
    /usr/local/golang/1.6.1/go/src/net/http/transport.go:1273 +0x563
created by net/http.(*Transport).dialConn
    /usr/local/golang/1.6.1/go/src/net/http/transport.go:854 +0x1715

It seems like the race condition is detected between net/http/httptest.(*Server).wrap and net/http/httptest.(*Server).forgetConn. I would very much appreciate it if somebody can point me to the Go code that I should investigate further.

Thanks in advance.

@gyuho gyuho changed the title net/http/httptest: possible race condition net/http/httptest: possible leaky goroutine May 11, 2016
@bradfitz bradfitz added this to the Go1.7Maybe milestone May 16, 2016
@bradfitz
Copy link
Contributor

I would very much appreciate it if somebody can point me to the Go code that I should investigate further.

The code is in the src/net/http/httptest directory. Or are you looking for something more specific than that? You seem to have already started investigating?

@gyuho
Copy link
Contributor Author

gyuho commented May 16, 2016

@bradfitz Yes, I am still trying to reliably reproduce this issue. You are right. Think the logs give enough information. Will post updates here if I get it to reproduce.

Thanks!

@bradfitz
Copy link
Contributor

Closing since there's no reliable repro or details, and because you've closed your upstream bug too.

@gyuho
Copy link
Contributor Author

gyuho commented May 20, 2016

I should've closed this earlier. Thanks, Brad.

I will revisit this when I can reproduce it.

@golang golang locked and limited conversation to collaborators May 20, 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

3 participants