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

slice bounds out of rang #22

Open
libangzhu opened this issue Feb 23, 2021 · 3 comments
Open

slice bounds out of rang #22

libangzhu opened this issue Feb 23, 2021 · 3 comments

Comments

@libangzhu
Copy link

libangzhu commented Feb 23, 2021

`panic: runtime error: slice bounds out of range [:826] with capacity 512

goroutine 9921985 [running]:
github.com/libp2p/go-msgio.(*reader).ReadMsg(0xc00c5d44c0, 0x0, 0x0, 0x0, 0x0, 0x0)
D:/goWork/pkg/mod/github.com/libp2p/[email protected]/msgio.go:235 +0x2dc
github.com/libp2p/go-libp2p-secio.(*etmReader).fill(0xc0052e34a0, 0x1de, 0x0)
D:/goWork/pkg/mod/github.com/libp2p/[email protected]/rw.go:132 +0x3f
github.com/libp2p/go-libp2p-secio.(*etmReader).Read(0xc0052e34a0, 0xc00c525cd0, 0xc, 0xc, 0x0, 0x0, 0x0)
D:/goWork/pkg/mod/github.com/libp2p/[email protected]/rw.go:171 +0x2a5
io.ReadAtLeast(0x2a09e810, 0xc003127000, 0xc00c525cd0, 0xc, 0xc, 0xc, 0xc, 0x0, 0x0)
C:/Go/src/io/io.go:310 +0x8e
io.ReadFull(...)
C:/Go/src/io/io.go:329
github.com/libp2p/go-yamux.(*Session).recvLoop(0xc000131ce0, 0x0, 0x0)
D:/goWork/pkg/mod/github.com/libp2p/[email protected]/session.go:526 +0xe1
github.com/libp2p/go-yamux.(*Session).recv(0xc000131ce0)
D:/goWork/pkg/mod/github.com/libp2p/[email protected]/session.go:505 +0x32
created by github.com/libp2p/go-yamux.newSession
D:/goWork/pkg/mod/github.com/libp2p/[email protected]/session.go:125 +0x380
panic: runtime error: slice bounds out of range [:2158] with capacity 2048

goroutine 4538928 [running]:
github.com/libp2p/go-msgio.(*reader).ReadMsg(0xc00a7aae40, 0x0, 0x0, 0x0, 0x0, 0x0)
D:/goWork/pkg/mod/github.com/libp2p/[email protected]/msgio.go:235 +0x2dc
github.com/libp2p/go-libp2p-secio.(*etmReader).fill(0xc00066e500, 0x65d, 0x0)
D:/goWork/pkg/mod/github.com/libp2p/[email protected]/rw.go:132 +0x3f
github.com/libp2p/go-libp2p-secio.(*etmReader).Read(0xc00066e500, 0xc006460390, 0xc, 0xc, 0x0, 0x0, 0x0)
D:/goWork/pkg/mod/github.com/libp2p/[email protected]/rw.go:171 +0x2a5
io.ReadAtLeast(0x2a4a9c88, 0xc005b4a000, 0xc006460390, 0xc, 0xc, 0xc, 0xc, 0x0, 0x0)
C:/Go/src/io/io.go:310 +0x8e
io.ReadFull(...)
C:/Go/src/io/io.go:329
github.com/libp2p/go-yamux.(*Session).recvLoop(0xc001960e00, 0x0, 0x0)
D:/goWork/pkg/mod/github.com/libp2p/[email protected]/session.go:526 +0xe1
github.com/libp2p/go-yamux.(*Session).recv(0xc001960e00)
D:/goWork/pkg/mod/github.com/libp2p/[email protected]/session.go:505 +0x32
created by github.com/libp2p/go-yamux.newSession
D:/goWork/pkg/mod/github.com/libp2p/[email protected]/session.go:125 +0x380
panic: runtime error: slice bounds out of range [:798] with capacity 512

`

the go-msgio version we use is v0.0.6
#16
33cn/chain33/issues/1000

@marten-seemann
Copy link
Contributor

Thank you for reporting! This looks like a bug, will investigate.

@marten-seemann marten-seemann self-assigned this Feb 23, 2021
@marten-seemann
Copy link
Contributor

It doesn't look like the bug is in this package though:

go-msgio/msgio.go

Lines 229 to 235 in 7083218

read, err := io.ReadFull(s.R, msg)
if read < length {
s.next = length - read // we only partially consumed the message.
} else {
s.next = -1 // signal we've consumed this msg
}
return msg[:read], err

read will always be smaller or equal len(msg), so taking msg[:read] should never be an invalid operation.

This looks exactly like #16.

@marten-seemann marten-seemann removed their assignment Feb 23, 2021
@libangzhu
Copy link
Author

It doesn't look like the bug is in this package though:

go-msgio/msgio.go

Lines 229 to 235 in 7083218

read, err := io.ReadFull(s.R, msg)
if read < length {
s.next = length - read // we only partially consumed the message.
} else {
s.next = -1 // signal we've consumed this msg
}
return msg[:read], err

read will always be smaller or equal len(msg), so taking msg[:read] should never be an invalid operation.
This looks exactly like #16.

this problem just occasional on windows, and we are confused those code seems impossible to have a panic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants