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

transport.CloseIdleConnections() nils map, putIdleConn() doesn't check for nil and panics #3266

Closed
ancientlore opened this issue Mar 9, 2012 · 2 comments

Comments

@ancientlore
Copy link

What steps will reproduce the problem?
1. Running a heavily utilized network service, like a crawler with 100 threads.
2. Call transport.CloseIdleConnections(), which nils the idleConn member.
3. At some point the transport's putIdleConn() function is called, resulting in a
runtime panic because the map is nil.

What is the expected output?

Not to panic - putIdleConn() should recreate the map like getIdleConn() does.

What do you see instead?

panic: runtime error: assignment to entry in nil map

goroutine 65 [running]:
net/http.(*Transport).putIdleConn(0xf8400bcdc0, 0xf8401c7f00, 0x0, 0xf8404edca6,
0xf84025cf18, ...)
    /home/michael/go/src/pkg/net/http/transport.go:263 +0x1c7
net/http._func_009(0xf84025cf18, 0xf84025ccf8, 0xf84025cb18, 0x44a2ce, 0xf840de81c0, ...)
    /home/michael/go/src/pkg/net/http/transport.go:575 +0x33
net/http.(*bodyEOFSignal).Close(0xf8405bb3c0, 0x0, 0x0, 0x0)
    /home/michael/go/src/pkg/net/http/transport.go:719 +0xb6
main.(*FilePoster).posterThread(0xf84008f780, 0xf8400ee780, 0xf80000003d, 0x0, 0x0, ...)
    /home/michael/gocode/src/concur/autoposter/httppost.go:94 +0x1b29
created by main.(*FilePoster).Start
    /home/michael/gocode/src/concur/autoposter/fileposter.go:64 +0x349

Which compiler are you using (5g, 6g, 8g, gccgo)?

6g

Which operating system are you using?

Ubuntu Linux

Which revision are you using?  (hg identify)

f4470a54e6db weekly/weekly.2012-03-04

Please provide any additional information below.

I inspected the latest version of /src/pkg/net/http/transport.go and noticed the issue
while investigating the panic. The panic does not occur if you don't call
CloseIdleConnections().

If you add:

if t.idleConn == nil {
  t.idleConn = make(map[string][]*persistConn)
}

at line 247 in transport.go I believe it will fix it.
@bradfitz
Copy link
Contributor

Comment 1:

Thanks!
Fix & test here:
http://golang.org/cl/5754068

Owner changed to @bradfitz.

Status changed to Started.

@bradfitz
Copy link
Contributor

Comment 2:

This issue was closed by revision b2e9f42.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
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