-
Notifications
You must be signed in to change notification settings - Fork 18k
net/http: segfault in bufio #7092
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
Labels
Comments
But it isn't 1, it's actually nil. That is, you can patch src/pkg/bufio/bufio.go and add before line 152 the code if b.rd == nil { panic("b.rd is nil!") } it will trigger. I don't know how the runtime comes up with addr=0x1. The actual instruction that faults is: mov 0x14(%ecx),%ebx where %ecx is loaded from the itab slot of the nil b.rd. So addr should be 0x14. |
It gets the right address on arm... panic: runtime error: invalid memory address or nil pointer dereference [signal 0xb code=0x1 addr=0x14 pc=0x1683d0] goroutine 749 [running]: runtime.panic(0x2e8920, 0x6ab3b0) /tmp/gobuilder/linux-arm-luitvd-9d797d0b899b/go/src/pkg/runtime/panic.c:264 +0x134 bufio.(*Reader).Read(0x11062270, 0x10a8b000, 0x1000, 0x1000, 0x1000, ...) /tmp/gobuilder/linux-arm-luitvd-9d797d0b899b/go/src/pkg/bufio/bufio.go:152 +0x12c net/http.(*chunkedReader).Read(0x10ca9c60, 0x10a8b000, 0x1000, 0x1000, 0x4, ...) /tmp/gobuilder/linux-arm-luitvd-9d797d0b899b/go/src/pkg/net/http/chunked.go:73 +0x16c net/http.(*body).readLocked(0x11062660, 0x10a8b000, 0x1000, 0x1000, 0x0, ...) /tmp/gobuilder/linux-arm-luitvd-9d797d0b899b/go/src/pkg/net/http/transfer.go:544 +0x74 net/http.(*body).Read(0x11062660, 0x10a8b000, 0x1000, 0x1000, 0x0, ...) /tmp/gobuilder/linux-arm-luitvd-9d797d0b899b/go/src/pkg/net/http/transfer.go:539 +0x10c io.(*LimitedReader).Read(0x10f33590, 0x10a8b000, 0x1000, 0x1000, 0xf84, ...) /tmp/gobuilder/linux-arm-luitvd-9d797d0b899b/go/src/pkg/io/io.go:398 +0x130 bufio.(*Writer).ReadFrom(0x10c9ce20, 0xb6def6a0, 0x10f33590, 0x80f85, 0x0, ...) /tmp/gobuilder/linux-arm-luitvd-9d797d0b899b/go/src/pkg/bufio/bufio.go:622 +0x1a0 io.Copy(0xb6df0ea8, 0x10c9ce20, 0xb6def6a0, 0x10f33590, 0x0, ...) /tmp/gobuilder/linux-arm-luitvd-9d797d0b899b/go/src/pkg/io/io.go:348 +0x120 net/http.(*transferWriter).WriteBody(0x10ab5940, 0xb6df0ea8, 0x10c9ce20, 0x0, 0x0) /tmp/gobuilder/linux-arm-luitvd-9d797d0b899b/go/src/pkg/net/http/transfer.go:197 +0x63c net/http.(*Request).write(0x10b85460, 0xb6df0ea8, 0x10c9ce20, 0x0, 0x10c9ce80, ...) /tmp/gobuilder/linux-arm-luitvd-9d797d0b899b/go/src/pkg/net/http/request.go:401 +0x730 net/http.(*persistConn).writeLoop(0x10b90c80) /tmp/gobuilder/linux-arm-luitvd-9d797d0b899b/go/src/pkg/net/http/transport.go:797 +0x194 created by net/http.(*Transport).dialConn /tmp/gobuilder/linux-arm-luitvd-9d797d0b899b/go/src/pkg/net/http/transport.go:529 +0x604 |
I think this is a bug in net/http. CL 50760043 triggers every few runs for me. Someone is using the bufio.Reader after putBufioReader is called. I did get it to fail on 64 bit. Seems to happen less often for some reason. panic: bufio.Read from trashed Reader goroutine 749 [running]: runtime.panic(0x8283540, 0x18fb8ed0) /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/runtime/panic.c:264 +0xac bufio.(*Reader).Read(0x18b12ed0, 0x18b8e000, 0x1000, 0x1000, 0x18b2a73c, ...) /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/bufio/bufio.go:143 +0x78 net/http.(*chunkedReader).Read(0x18af7760, 0x18b8e000, 0x1000, 0x1000, 0x18a90008, ...) /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/net/http/chunked.go:73 +0x10f net/http.(*body).readLocked(0x18b2a720, 0x18b8e000, 0x1000, 0x1000, 0x0, ...) /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/net/http/transfer.go:544 +0x58 net/http.(*body).Read(0x18b2a720, 0x18b8e000, 0x1000, 0x1000, 0x0, ...) /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/net/http/transfer.go:539 +0xcb io.(*LimitedReader).Read(0x19008550, 0x18b8e000, 0x1000, 0x1000, 0xf8c, ...) /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/io/io.go:398 +0xc4 bufio.(*Writer).ReadFrom(0x1910e340, 0xf77cb6f8, 0x19008550, 0x83f85, 0x0, ...) /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/bufio/bufio.go:626 +0x139 io.Copy(0xf77cce90, 0x1910e340, 0xf77cb6f8, 0x19008550, 0x0, ...) /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/io/io.go:348 +0xe7 net/http.(*transferWriter).WriteBody(0x18c1bc00, 0xf77cce90, 0x1910e340, 0x0, 0x0) /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/net/http/transfer.go:197 +0x50d net/http.(*Request).write(0x18bd00e0, 0xf77cce90, 0x1910e340, 0x808a200, 0x18af7b00, ...) /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/net/http/request.go:401 +0x697 net/http.(*persistConn).writeLoop(0x18bd79b0) /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/net/http/transport.go:797 +0x163 created by net/http.(*Transport).dialConn /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/net/http/transport.go:529 +0x553 panic: bufio.Read from trashed Reader goroutine 749 [running]: runtime.panic(0x6c51c0, 0xc210632380) /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/runtime/panic.c:264 +0xb6 bufio.(*Reader).Read(0xc21030f360, 0xc210f85000, 0x1000, 0x1000, 0xc21091fbf0, ...) /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/bufio/bufio.go:143 +0xa8 net/http.(*chunkedReader).Read(0xc2107b3720, 0xc210f85000, 0x1000, 0x1000, 0xc2101d9010, ...) /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/net/http/chunked.go:73 +0x168 net/http.(*body).readLocked(0xc21091fbc0, 0xc210f85000, 0x1000, 0x1000, 0x0, ...) /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/net/http/transfer.go:544 +0x64 net/http.(*body).Read(0xc21091fbc0, 0xc210f85000, 0x1000, 0x1000, 0x0, ...) /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/net/http/transfer.go:539 +0xe7 io.(*LimitedReader).Read(0xc210920c40, 0xc210f85000, 0x1000, 0x1000, 0x8e, ...) /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/io/io.go:398 +0xc6 bufio.(*Writer).ReadFrom(0xc21091f040, 0x7fd849e8cbe8, 0xc210920c40, 0x82f85, 0x0, ...) /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/bufio/bufio.go:626 +0x16e io.Copy(0x7fd849e8ea48, 0xc21091f040, 0x7fd849e8cbe8, 0xc210920c40, 0x0, ...) /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/io/io.go:348 +0x124 net/http.(*transferWriter).WriteBody(0xc21052e620, 0x7fd849e8ea48, 0xc21091f040, 0x0, 0x0) /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/net/http/transfer.go:197 +0x60e net/http.(*Request).write(0xc210048270, 0x7fd849e8ea48, 0xc21091f040, 0x405c00, 0xc2107e59c0, ...) /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/net/http/request.go:401 +0x88d net/http.(*persistConn).writeLoop(0xc2107a7f80) /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/net/http/transport.go:797 +0x1c7 created by net/http.(*Transport).dialConn /usr/local/google/home/khr/sandbox/go-issue7092/src/pkg/net/http/transport.go:529 +0x6ad |
Quick repro, even in Linux/amd64 any GOMAXPROCS... $ while ./http.test -test.v -test.short -test.cpu=8,8,8,8 -test.run=TestTransportAndServerSharedBodyRace; do true; done The TestTransportAndServerSharedBodyRace test was added last week and tests the case of a server passing off its Request.Body to the HTTP client. That new test is exposing yet another bug in this same area. The assumption that the server owned the Request.Body exclusively was wrong. Will fix. Status changed to Accepted. |
Sent https://golang.org/cl/51700043/ Status changed to Started. |
*** Submitted as https://code.google.com/p/go/source/detail?r=51a204237ba5 *** Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: