libp2p / go-libp2p

libp2p implementation in Go
MIT License
6.03k stars 1.06k forks source link

panic: runtime error: slice bounds out of range #2444

Open Shawn-Huang-Tron opened 1 year ago

Shawn-Huang-Tron commented 1 year ago
v0.24.2

caught panic: runtime error: slice bounds out of range [:19] with capacity 1
goroutine 2503483111 [running]:
runtime/debug.Stack()
/usr/local/go/src/runtime/debug/stack.go:24 +0x65
github.com/multiformats/go-multistream.SelectWithSimopenOrFail.func1()
pkg/mod/github.com/multiformats/go-multistream@v0.3.3/client.go:103 +0x58
panic({0x26c3f20, 0xc017c6a4f8})
/usr/local/go/src/runtime/panic.go:838 +0x207
github.com/libp2p/go-libp2p/p2p/net/pnet.(*pskConn).Read(0xc0b72b09c0, {0xc05920ab90, 0x10?, 0x1})
pkg/mod/github.com/libp2p/go-libp2p@v0.24.2/p2p/net/pnet/psk_conn.go:43 +0x185
github.com/multiformats/go-multistream.(*byteReader).ReadByte(0xc04ebcd770)
pkg/mod/github.com/multiformats/go-multistream@v0.3.3/multistream.go:328 +0x4e
github.com/multiformats/go-varint.ReadUvarint({0x385c7e0, 0xc04ebcd770})
pkg/mod/github.com/multiformats/go-varint@v0.0.7/varint.go:80 +0x5a
github.com/multiformats/go-multistream.lpReadBuf({0x21b2748ca18?, 0xc0b72b09c0})
pkg/mod/github.com/multiformats/go-multistream@v0.3.3/multistream.go:292 +0x94
github.com/multiformats/go-multistream.ReadNextTokenBytes({0x21b2748ca18?, 0xc0b72b09c0?})
pkg/mod/github.com/multiformats/go-multistream@v0.3.3/multistream.go:275 +0x27
github.com/multiformats/go-multistream.ReadNextToken(...)
pkg/mod/github.com/multiformats/go-multistream@v0.3.3/multistream.go:264
github.com/multiformats/go-multistream.SelectWithSimopenOrFail({0xc000cbfae0?, 0x2, 0x2}, {0x21b2748c9e8?, 0xc0b72b09c0})
pkg/mod/github.com/multiformats/go-multistream@v0.3.3/client.go:128 +0x1e5
github.com/libp2p/go-libp2p/p2p/net/upgrader.(*upgrader).negotiateSecurity.func1()
pkg/mod/github.com/libp2p/go-libp2p@v0.24.2/p2p/net/upgrader/upgrader.go:327 +0x167
created by github.com/libp2p/go-libp2p/p2p/net/upgrader.(*upgrader).negotiateSecurity
pkg/mod/github.com/libp2p/go-libp2p@v0.24.2/p2p/net/upgrader/upgrader.go:318 +0x112

Receive error a day or two later.

marten-seemann commented 1 year ago

Does this also happen with a recent version of go-libp2p?

Shawn-Huang-Tron commented 1 year ago

Didn't try in the recent version of go-libp2p, this error doesn't always happen, it's random.

marten-seemann commented 10 months ago

This looks similar to https://github.com/libp2p/go-yamux/issues/65. Interestingly, we thought that this bug only occurred on Windows, whereas here it seems to occur on Linux as well.