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

Panic in compress/gzip: index out of range #40008

Closed
aka-rider opened this issue Jul 2, 2020 · 2 comments
Closed

Panic in compress/gzip: index out of range #40008

aka-rider opened this issue Jul 2, 2020 · 2 comments

Comments

@aka-rider
Copy link

aka-rider commented Jul 2, 2020

What version of Go are you using (go version)?

go version go1.14.2 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/rider/Library/Caches/go-build"
GOENV="/Users/rider/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY="gitlab.com/aigent/"
GONOSUMDB="gitlab.com/aigent/
"
GOOS="darwin"
GOPATH="/Users/rider/wrk/go"
GOPRIVATE="gitlab.com/aigent/*"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.14.2_1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14.2_1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/rider/wrk/go/src/gitlab.com/aigent/platform/processing/kaldi-client/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/l8/_c7mlptn4zgbjb_xywymh2lm0000gn/T/go-build535733669=/tmp/go-build -gno-record-gcc-switches -fno-common"

Minimal code sample

The following snippet does not reproduce this panic, it should give an idea of what sequence of steps were used in the original application.

https://play.golang.org/p/6l6vN-hP006

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

goroutine 94 [running]:
compress/flate.(*huffmanBitWriter).indexTokens(0xc00000c3c0, 0xc0005b2000, 0xaf, 0x4001, 0xc0002ad5a0, 0x68624e)
	/usr/local/go/src/compress/flate/huffman_bit_writer.go:551 +0x2df
compress/flate.(*huffmanBitWriter).writeBlock(0xc00000c3c0, 0xc0005b2000, 0xaf, 0x4001, 0x0, 0xc0005ac522, 0x0, 0x5ade)
	/usr/local/go/src/compress/flate/huffman_bit_writer.go:440 +0xa1
compress/flate.(*compressor).writeBlock(0xc000700000, 0xc0005b2000, 0xae, 0x4001, 0xa522, 0x45, 0x0)
	/usr/local/go/src/compress/flate/deflate.go:170 +0xc5
compress/flate.(*compressor).deflate(0xc000700000)
	/usr/local/go/src/compress/flate/deflate.go:415 +0x8be
compress/flate.(*compressor).syncFlush(0xc000700000, 0x0, 0xc000081180)
	/usr/local/go/src/compress/flate/deflate.go:568 +0x50
compress/flate.(*Writer).Flush(...)
	/usr/local/go/src/compress/flate/deflate.go:727
compress/gzip.(*Writer).Flush(0xc0000e0a50, 0xac54c0, 0xc00035a500)
	/usr/local/go/src/compress/gzip/gzip.go:221 +0x5f
.........

goroutine 1890 [running]:
compress/flate.(*huffmanBitWriter).indexTokens(0xc00000c3c0, 0xc0005b2000, 0xaf, 0x4001, 0xc000aeb4f0, 0x68624e)
	/usr/local/go/src/compress/flate/huffman_bit_writer.go:551 +0x2df
compress/flate.(*huffmanBitWriter).writeBlock(0xc00000c3c0, 0xc0005b2000, 0xaf, 0x4001, 0x0, 0xc0005ac055, 0x4cd, 0x5fab)
	/usr/local/go/src/compress/flate/huffman_bit_writer.go:440 +0xa1
compress/flate.(*compressor).writeBlock(0xc000700000, 0xc0005b2000, 0xae, 0x4001, 0xa522, 0x58, 0x0)
	/usr/local/go/src/compress/flate/deflate.go:170 +0xc5
compress/flate.(*compressor).deflate(0xc000700000)
	/usr/local/go/src/compress/flate/deflate.go:415 +0x8be
compress/flate.(*compressor).write(0xc000700000, 0xc0000e6800, 0x305, 0x3ef, 0x3ef, 0xc0a35bef12, 0xc000aeb620)
	/usr/local/go/src/compress/flate/deflate.go:554 +0x83
compress/flate.(*Writer).Write(...)
	/usr/local/go/src/compress/flate/deflate.go:712
compress/gzip.(*Writer).Write(0xc0000e0a50, 0xc0000e6800, 0x305, 0x3ef, 0x0, 0x0, 0x88)
	/usr/local/go/src/compress/gzip/gzip.go:196 +0xc1
encoding/json.(*Encoder).Encode(0xc0000b1450, 0xac54c0, 0xc0001e6c80, 0xc00068d748, 0x40dc96)
	/usr/local/go/src/encoding/json/stream.go:231 +0x1ca
.........
@randall77
Copy link
Contributor

You have two goroutines using the same writer. That's a data race and is not allowed.
You should see a data race report when using the race detector (the -race option).

@aka-rider
Copy link
Author

Thanks for the clarification, I will look at it.

@golang golang locked and limited conversation to collaborators Jul 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants