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: recover veils some nil pointer deref crashes at server side, but that's the way of the net/http world #6943

Closed
mattn opened this issue Dec 13, 2013 · 5 comments

Comments

@mattn
Copy link
Member

mattn commented Dec 13, 2013

But report.

Here is a blog post takeing benchmark. He did

  ab -n 1000 -c 100 http://127.0.0.1:8080

But sometimes go occur panic. below is a stacktrace.

...
21:01:13 go.1   | goroutine 1079 [select]:
21:01:13 go.1   | net/http.(*persistConn).roundTrip(0xc21056d900, 0xc2101add70,
0xc21056d900, 0x0, 0x0)
21:01:13 go.1   |      
/usr/local/Cellar/go/1.2/libexec/src/pkg/net/http/transport.go:879 +0x6d6
21:01:13 go.1   | net/http.(*Transport).RoundTrip(0xc210057200, 0xc2106e3a90, 0x1, 0x0,
0x0)
21:01:13 go.1   |      
/usr/local/Cellar/go/1.2/libexec/src/pkg/net/http/transport.go:187 +0x391
21:01:13 go.1   | net/http.send(0xc2106e3a90, 0x56c290, 0xc210057200, 0x0, 0x0, ...)
21:01:13 go.1   |       /usr/local/Cellar/go/1.2/libexec/src/pkg/net/http/client.go:168
+0x37f
21:01:13 go.1   | net/http.(*Client).send(0xc2106e74b0, 0xc2106e3a90, 0x16, 0x1,
0xc2101add60)
21:01:13 go.1   |       /usr/local/Cellar/go/1.2/libexec/src/pkg/net/http/client.go:100
+0xd9
21:01:13 go.1   | net/http.(*Client).doFollowingRedirects(0xc2106e74b0, 0xc2106e3a90,
0x2af1f8, 0x0, 0x0, ...)
21:01:13 go.1   |       /usr/local/Cellar/go/1.2/libexec/src/pkg/net/http/client.go:294
+0x671
21:01:13 go.1   | net/http.(*Client).Do(0xc2106e74b0, 0xc2106e3a90, 0x485dc0, 0x0, 0x0)
21:01:13 go.1   |       /usr/local/Cellar/go/1.2/libexec/src/pkg/net/http/client.go:129
+0x8f
21:01:13 go.1   | github.com/kentaro/delta.(*Handler).dispatchProxyRequest(0xc2100001f0,
0xc210036960, 0xc2106b34e0, 0xc2106a7840, 0xc2106abee0)
21:01:13 go.1   |       /Users/usr0600239/.go/src/github.com/kentaro/delta/handler.go:71
+0xb0
21:01:13 go.1   | created by github.com/kentaro/delta.(*Handler).ServeHTTP
21:01:13 go.1   |       /Users/usr0600239/.go/src/github.com/kentaro/delta/handler.go:29
+0x1fa
21:01:13 go.1   |
21:01:13 go.1   | goroutine 1078 [chan receive]:
21:01:13 go.1   | github.com/kentaro/delta.func·001()
21:01:13 go.1   |       /Users/usr0600239/.go/src/github.com/kentaro/delta/handler.go:38
+0x80
21:01:13 go.1   | created by github.com/kentaro/delta.(*Handler).ServeHTTP
21:01:13 go.1   |       /Users/usr0600239/.go/src/github.com/kentaro/delta/handler.go:52
+0x258
21:01:13 go.1   |
21:01:13 go.1   | goroutine 1076 [select]:
21:01:13 go.1   | exited with code 2
21:01:13 system | sending SIGTERM to all processes
21:01:13 go.1   | exited with code 0

And he says, around over 5000 requests, go doesn't return response.
@mikioh
Copy link
Contributor

mikioh commented Dec 13, 2013

Comment 1:

Please use some debugger or other tool to tell us the detail of the issue. I just read
your friend's blog (in Japanese), it happens on OS X with Go 1.2, and now see a few bugs
in the code. For example, 
res, err := client.Do(proxyRequest)
if err != nil {
        log.Printf("HTTP Request Error: %s\n", err)
}
response, err := NewResponse(backend, res, elapsed) // this guy may touch a nil pointer
> go doesn't return response.
I believe that Go standard library reports resource exhaustion but the code ignores and
tries to continue a chicken race, in that case ulimit or launchctl would be a solution.

Status changed to Retracted.

@mattn
Copy link
Member Author

mattn commented Dec 13, 2013

Comment 3:

Do you mean code of delta?
https://github.com/kentaro/delta/blob/master/handler.go#L77-L90
if return err, the code doesn't refer res as nil. I guess.

@mikioh
Copy link
Contributor

mikioh commented Dec 13, 2013

Comment 4:

Glad to hear it's fixed.

@mikioh
Copy link
Contributor

mikioh commented Dec 13, 2013

Comment 5:

Also your friend may need to modify /etc/launchd.conf like:
% cat /etc/launchd.conf 
limit maxfiles 8192 8192

@mattn
Copy link
Member Author

mattn commented Dec 13, 2013

Comment 6:

Sure, but I can't understand why perl pass all requests.

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