Skip to content

net/http: segfault in bufio #7092

Closed
Closed
@randall77

Description

@randall77
Happens only a few percent of the time.  Looks like the b.rd field is nil.

env GOARCH=386 ./make.bash
env GOARCH=386 ../bin/go test -c net/http
cd pkg/net/http
env GOMAXPROCS=4 ../../../http.test -test.short

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x1 pc=0x8168594]

goroutine 748 [running]:
runtime.panic(0x82e0d20, 0x86c2c28)
    /usr/local/google/home/khr/sandbox/go-issue7083/src/pkg/runtime/panic.c:264 +0xac
bufio.(*Reader).Read(0x18cd1510, 0x18b0e000, 0x1000, 0x1000, 0x1000, ...)
    /usr/local/google/home/khr/sandbox/go-issue7083/src/pkg/bufio/bufio.go:152 +0xc4
net/http.(*chunkedReader).Read(0x18bce9c0, 0x18b0e000, 0x1000, 0x1000, 0x18af6808, ...)
    /usr/local/google/home/khr/sandbox/go-issue7083/src/pkg/net/http/chunked.go:73 +0x10f
net/http.(*body).readLocked(0x18c38930, 0x18b0e000, 0x1000, 0x1000, 0x0, ...)
    /usr/local/google/home/khr/sandbox/go-issue7083/src/pkg/net/http/transfer.go:544 +0x58
net/http.(*body).Read(0x18c38930, 0x18b0e000, 0x1000, 0x1000, 0x0, ...)
    /usr/local/google/home/khr/sandbox/go-issue7083/src/pkg/net/http/transfer.go:539 +0xcb
io.(*LimitedReader).Read(0x18b57fb0, 0x18b0e000, 0x1000, 0x1000, 0xf8c, ...)
    /usr/local/google/home/khr/sandbox/go-issue7083/src/pkg/io/io.go:398 +0xc4
bufio.(*Writer).ReadFrom(0x18bcecc0, 0xf779c698, 0x18b57fb0, 0x84f85, 0x0, ...)
    /usr/local/google/home/khr/sandbox/go-issue7083/src/pkg/bufio/bufio.go:622 +0x139
io.Copy(0xf779de20, 0x18bcecc0, 0xf779c698, 0x18b57fb0, 0x0, ...)
    /usr/local/google/home/khr/sandbox/go-issue7083/src/pkg/io/io.go:348 +0xe7
net/http.(*transferWriter).WriteBody(0x18ca09c0, 0xf779de20, 0x18bcecc0, 0x0, 0x0)
    /usr/local/google/home/khr/sandbox/go-issue7083/src/pkg/net/http/transfer.go:197 +0x50d
net/http.(*Request).write(0x18a5c2a0, 0xf779de20, 0x18bcecc0, 0x18a6f900, 0x18c2cf60,
...)
    /usr/local/google/home/khr/sandbox/go-issue7083/src/pkg/net/http/request.go:401 +0x697
net/http.(*persistConn).writeLoop(0x18c2d6e0)
    /usr/local/google/home/khr/sandbox/go-issue7083/src/pkg/net/http/transport.go:797 +0x163
created by net/http.(*Transport).dialConn
    /usr/local/google/home/khr/sandbox/go-issue7083/src/pkg/net/http/transport.go:529 +0x553

I suspect net/http/server.go:putBufioReader, it's the only one that clears the rd field.
 If I comment out the body of this function, the bug goes away.

Perhaps someone is still using the bufio.Reader when it is put in the pool?  Ah, the
dangers of manual memory management...

Seems to happen only in 32 bit and with GOMAXPROCS>1.  Why?  I have no idea.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions