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

s2 compression panic: index out of range [0] with length 0 #929

Closed
iamcalledrob opened this issue Feb 20, 2024 · 3 comments · Fixed by #930
Closed

s2 compression panic: index out of range [0] with length 0 #929

iamcalledrob opened this issue Feb 20, 2024 · 3 comments · Fixed by #930

Comments

@iamcalledrob
Copy link

I think this may be a separate issue to #902, so opening another one.

I'm encountering a panic when compressing a specific stream of data with s2. It looks like there may be a missing bounds check when emitting repeat chunks?

panic: runtime error: index out of range [0] with length 0

goroutine 251 [running]:
github.com/klauspost/compress/s2.emitRepeat({0x140009e400b?, 0x0?, 0x0?}, 0x140009e1f78?, 0x0?)
	/Users/rob/go/pkg/mod/github.com/klauspost/compress@v1.17.6/s2/encode_go.go:111 +0x1e0
github.com/klauspost/compress/s2.encodeBlockGo({0x140009e400b, 0x10004, 0x10004}, {0x140009d2008, 0x10000, 0x10007})
	/Users/rob/go/pkg/mod/github.com/klauspost/compress@v1.17.6/s2/encode_all.go:146 +0x938
github.com/klauspost/compress/s2.encodeBlock(...)
	/Users/rob/go/pkg/mod/github.com/klauspost/compress@v1.17.6/s2/encode_go.go:24
github.com/klauspost/compress/s2.(*Writer).encodeBlock(0x140009d2008?, {0x140009e400b?, 0x0?, 0x140003dcee0?}, {0x140009d2008?, 0x103bbf0f4?, 0x1400053e0a0?})
	/Users/rob/go/pkg/mod/github.com/klauspost/compress@v1.17.6/s2/writer.go:457 +0x178
github.com/klauspost/compress/s2.(*Writer).writeFull.func1()
	/Users/rob/go/pkg/mod/github.com/klauspost/compress@v1.17.6/s2/writer.go:599 +0x128
created by github.com/klauspost/compress/s2.(*Writer).writeFull in goroutine 235
	/Users/rob/go/pkg/mod/github.com/klauspost/compress@v1.17.6/s2/writer.go:590 +0x388

The stream in question is 185gb, but this crash occurs fairly early within it, and reproduces every time on arm64 (Darwin, M-series)

I'll look at following up with a more straightforward test case.

@klauspost
Copy link
Owner

Thanks. This should be enough for me to locate it.

@iamcalledrob
Copy link
Author

Thank you so much for fixing this. Really appreciated.

@klauspost
Copy link
Owner

Thanks for the report! Published a new version.

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

Successfully merging a pull request may close this issue.

2 participants