Skip to content

panic: runtime error: slice bounds out of range in bufio -> net/textproto #1725

@gopherbot

Description

@gopherbot

by tarmigan:

I have a go program that does about 3000 http.Get() calls and parses the results.  This
program used to work (last time I rebuilt it was few months ago), but after updating to
hg 14e85394f65e ("http: close underlying gzip Reader too") it panics.  
Looking at the backtrace, I don't think my program is at fault.  Looks like bufio got
into an inconsistent state somehow.  I have reproduced it twice now, so I may be able to
add debugging prints if needed.

GOOS=darwin GOARCH=386

Thanks,
Tarmigan


panic: runtime error: slice bounds out of range

runtime.panic+0x92 /Users/tarm/devel/go/src/pkg/runtime/proc.c:1034
    runtime.panic(0xf1a8c, 0x10b19018)
runtime.panicstring+0x8f /Users/tarm/devel/go/src/pkg/runtime/runtime.c:116
    runtime.panicstring(0x1d5879, 0x0)
runtime.panicslice+0x24 /Users/tarm/devel/go/src/pkg/runtime/runtime.c:79
    runtime.panicslice()
bufio.*Reader·ReadSlice+0x6b /Users/tarm/devel/go/src/pkg/bufio/bufio.go:252
    bufio.*Reader·ReadSlice(0x10906f90, 0xa, 0x0, 0x0, 0x0, ...)
bufio.*Reader·ReadBytes+0x84 /Users/tarm/devel/go/src/pkg/bufio/bufio.go:327
    bufio.*Reader·ReadBytes(0x10906f90, 0xa, 0x0, 0x0, 0x0, ...)
net/textproto.*Reader·ReadLineBytes+0x39
/Users/tarm/devel/go/src/pkg/net/textproto/reader.go:43
    net/textproto.*Reader·ReadLineBytes(0x10b19010, 0x0, 0x0)
net/textproto.*Reader·ReadLine+0x26
/Users/tarm/devel/go/src/pkg/net/textproto/reader.go:36
    net/textproto.*Reader·ReadLine(0x10b19010, 0x3, 0x105a98)
http.ReadResponse+0x96 /Users/tarm/devel/go/src/pkg/http/response.go:88
    http.ReadResponse(0x10906f90, 0x105a98, 0x3, 0x10855300, 0x0, ...)
http.readResponseWithEOFSignal+0x3b /Users/tarm/devel/go/src/pkg/http/transport.go:577
    http.readResponseWithEOFSignal(0x10906f90, 0x105a98, 0x3, 0x0, 0x0, ...)
http.*ClientConn·Read+0x2fd /Users/tarm/devel/go/src/pkg/http/persist.go:368
    http.*ClientConn·Read(0x10a7d930, 0x10d04e00, 0x0, 0x0, 0x0, ...)
http.*persistConn·readLoop+0x246 /Users/tarm/devel/go/src/pkg/http/transport.go:450
    http.*persistConn·readLoop(0x108fbd00, 0xea23)
runtime.goexit /Users/tarm/devel/go/src/pkg/runtime/proc.c:178
    runtime.goexit()
----- goroutine created by -----
http.*Transport·getConn+0x4db /Users/tarm/devel/go/src/pkg/http/transport.go:289

goroutine 5470 [4]:
runtime.gosched+0x61 /Users/tarm/devel/go/src/pkg/runtime/proc.c:600
    runtime.gosched()
runtime.chanrecv+0x3af /Users/tarm/devel/go/src/pkg/runtime/chan.c:329
    runtime.chanrecv(0x108c9b40, 0x67ee38, 0x0, 0x0, 0x67ee40, ...)
runtime.chanrecv1+0x3f /Users/tarm/devel/go/src/pkg/runtime/chan.c:424
    runtime.chanrecv1(0x108c9b40, 0x108551e0)
http.*persistConn·readLoop+0x437 /Users/tarm/devel/go/src/pkg/http/transport.go:481
    http.*persistConn·readLoop(0x10987200, 0xea23)
runtime.goexit /Users/tarm/devel/go/src/pkg/runtime/proc.c:178
    runtime.goexit()
----- goroutine created by -----
http.*Transport·getConn+0x4db /Users/tarm/devel/go/src/pkg/http/transport.go:289

goroutine 5469 [4]:
runtime.gosched+0x61 /Users/tarm/devel/go/src/pkg/runtime/proc.c:600
    runtime.gosched()
runtime.chanrecv+0x3af /Users/tarm/devel/go/src/pkg/runtime/chan.c:329
    runtime.chanrecv(0x108c96c0, 0x67de38, 0x0, 0x0, 0x67de40, ...)
runtime.chanrecv1+0x3f /Users/tarm/devel/go/src/pkg/runtime/chan.c:424
    runtime.chanrecv1(0x108c96c0, 0x10855120)
http.*persistConn·readLoop+0x437 /Users/tarm/devel/go/src/pkg/http/transport.go:481
    http.*persistConn·readLoop(0x108c9800, 0xea23)
runtime.goexit /Users/tarm/devel/go/src/pkg/runtime/proc.c:178
    runtime.goexit()
----- goroutine created by -----
http.*Transport·getConn+0x4db /Users/tarm/devel/go/src/pkg/http/transport.go:289

goroutine 5420 [1]:
runtime.gosched+0x61 /Users/tarm/devel/go/src/pkg/runtime/proc.c:600
    runtime.gosched()
runtime.exitsyscall+0x64 /Users/tarm/devel/go/src/pkg/runtime/proc.c:665
    runtime.exitsyscall()
syscall.Syscall6+0x4b /Users/tarm/devel/go/src/pkg/syscall/asm_darwin_386.s:61
    syscall.Syscall6()
syscall.kevent+0x58 /Users/tarm/devel/go/src/pkg/syscall/zsyscall_darwin_386.go:158
    syscall.kevent(0x11, 0x1082cfd8, 0x1, 0x1082cfd8, 0x1, ...)
syscall.Kevent+0x84 /Users/tarm/devel/go/src/pkg/syscall/syscall_bsd.go:441
    syscall.Kevent(0x11, 0x1082cfd8, 0x1, 0x1, 0x1082cfd8, ...)
net.*pollster·AddFD+0x133 /Users/tarm/devel/go/src/pkg/net/fd_darwin.go:54
    net.*pollster·AddFD(0x1082cf00, 0x29, 0x72, 0x0, 0x8, ...)
net.*pollServer·AddFD+0x1b0 /Users/tarm/devel/go/src/pkg/net/fd.go:125
    net.*pollServer·AddFD(0x108a1f90, 0x10be6e00, 0x72, 0x4)
net.*pollServer·WaitRead+0x36 /Users/tarm/devel/go/src/pkg/net/fd.go:254
    net.*pollServer·WaitRead(0x108a1f90, 0x10be6e00, 0x1000)
net.*netFD·Read+0x1be /Users/tarm/devel/go/src/pkg/net/fd.go:380
    net.*netFD·Read(0x10be6e00, 0x10a76000, 0x1000, 0x1000, 0x0, ...)
net.*TCPConn·Read+0x6d /Users/tarm/devel/go/src/pkg/net/tcpsock.go:94
    net.*TCPConn·Read(0x109e1bf8, 0x10a76000, 0x1000, 0x1000, 0x0, ...)
bufio.*Reader·fill+0x14f /Users/tarm/devel/go/src/pkg/bufio/bufio.go:97
    bufio.*Reader·fill(0x10ba1900, 0x20)
bufio.*Reader·Peek+0xb5 /Users/tarm/devel/go/src/pkg/bufio/bufio.go:116
    bufio.*Reader·Peek(0x10ba1900, 0x1, 0x0, 0x0)
http.*persistConn·readLoop+0x7f /Users/tarm/devel/go/src/pkg/http/transport.go:433
    http.*persistConn·readLoop(0x10ab6600, 0xea23)
runtime.goexit /Users/tarm/devel/go/src/pkg/runtime/proc.c:178
    runtime.goexit()
----- goroutine created by -----
http.*Transport·getConn+0x4db /Users/tarm/devel/go/src/pkg/http/transport.go:289

goroutine 5286 [4]:
runtime.gosched+0x61 /Users/tarm/devel/go/src/pkg/runtime/proc.c:600
    runtime.gosched()
runtime.chanrecv+0x14d /Users/tarm/devel/go/src/pkg/runtime/chan.c:361
    runtime.chanrecv(0x109873c0, 0x673b78, 0x0, 0x0, 0x1000, ...)
runtime.chanrecv1+0x3f /Users/tarm/devel/go/src/pkg/runtime/chan.c:424
    runtime.chanrecv1(0x109873c0, 0x10f37c00)
net.*pollServer·WaitRead+0x47 /Users/tarm/devel/go/src/pkg/net/fd.go:255
    net.*pollServer·WaitRead(0x108a1f90, 0x10f37c00, 0x1000)
net.*netFD·Read+0x1be /Users/tarm/devel/go/src/pkg/net/fd.go:380
    net.*netFD·Read(0x10f37c00, 0x111ba000, 0x1000, 0x1000, 0x0, ...)
net.*TCPConn·Read+0x6d /Users/tarm/devel/go/src/pkg/net/tcpsock.go:94
    net.*TCPConn·Read(0x109e1858, 0x111ba000, 0x1000, 0x1000, 0x0, ...)
bufio.*Reader·fill+0x14f /Users/tarm/devel/go/src/pkg/bufio/bufio.go:97
    bufio.*Reader·fill(0x10f2a8d0, 0x20)
bufio.*Reader·Peek+0xb5 /Users/tarm/devel/go/src/pkg/bufio/bufio.go:116
    bufio.*Reader·Peek(0x10f2a8d0, 0x1, 0x0, 0x0)
http.*persistConn·readLoop+0x7f /Users/tarm/devel/go/src/pkg/http/transport.go:433
    http.*persistConn·readLoop(0x10c52840, 0xea23)
runtime.goexit /Users/tarm/devel/go/src/pkg/runtime/proc.c:178
    runtime.goexit()
----- goroutine created by -----

[ more backtrace.  Can include if needed]

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