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

compress/gzip: Reset should work on an uninitialized Reader. #8126

Closed
gopherbot opened this issue May 30, 2014 · 4 comments
Closed

compress/gzip: Reset should work on an uninitialized Reader. #8126

gopherbot opened this issue May 30, 2014 · 4 comments

Comments

@gopherbot
Copy link

by travis.bischel:

gzip Reset should work on an uninitialized gzip Reader.

This goes along with this discussion:
https://groups.google.com/forum/#!topic/golang-dev/e7E6viMqwN0

What does 'go version' print?
go version devel +f8b50ad4cac4 Mon Apr 21 17:00:27 2014 -0700 + linux/amd64

What steps reproduce the problem?
http://play.golang.org/p/9F1Tn1pZ9O

What happened?
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x28 pc=0x429fa9]

goroutine 16 [running]:
runtime.panic(0x4dd680, 0x593853)
    /usr/local/go/src/pkg/runtime/panic.c:279 +0xf5
compress/gzip.(*Reader).Reset(0xc2081b2000, 0x7f92548af4e0, 0xc20802c070, 0x0, 0x0)
    /home/twmb/fastly/shared/dev/go/go1.3beta1/src/pkg/compress/gzip/gunzip.go:97 +0x69
main.main()
    /home/twmb/demonstrate.go:22 +0x1bd

goroutine 17 [runnable]:
runtime.MHeap_Scavenger()
    /usr/local/go/src/pkg/runtime/mheap.c:507
runtime.goexit()
    /usr/local/go/src/pkg/runtime/proc.c:1430

goroutine 18 [runnable]:
bgsweep()
    /usr/local/go/src/pkg/runtime/mgc0.c:1960
runtime.goexit()
    /usr/local/go/src/pkg/runtime/proc.c:1430

goroutine 19 [runnable]:
runfinq()
    /usr/local/go/src/pkg/runtime/mgc0.c:2586
runtime.goexit()
    /usr/local/go/src/pkg/runtime/proc.c:1430
exit status 2

What should have happened instead?
hello should be printed.

Please provide any additional information below.
Line 97 of http://tip.golang.org/src/pkg/compress/gzip/gunzip.go, digest is nil because
it is an uninitialized pointer. This could be fixed by having an

if digest == nil {
        z.digest = crc32.NewIEEE()
}

before the z.digest.Reset() call.

NewReader must be called first to initialize digest. If I want to gunzip in a for loop,
I currently must seed the unzipr with valid data before calling Reset on every
iteration. This is not a critical issue, but it would need to go out before 1.3 is
released otherwise doing this issue would break the same API compatibility discussed in
the golang-dev thread. Or, this issue could be shot down.
@gopherbot
Copy link
Author

Comment 1:

CL https://golang.org/cl/103020044 mentions this issue.

@ianlancetaylor
Copy link
Contributor

Comment 2:

This issue was closed by revision 68bbf9d.

Status changed to Fixed.

@gopherbot
Copy link
Author

Comment 3:

CL https://golang.org/cl/105820043 mentions this issue.

@dsymonds
Copy link
Contributor

dsymonds commented Jun 4, 2014

Comment 4:

This issue was closed by revision 71651c3afd06.

@gopherbot gopherbot added the fixed label Jun 4, 2014
dsymonds added a commit that referenced this issue May 11, 2015
…ewReader

««« CL 103020044 / 318b56ffe04b
compress/gzip: allow Reset on Reader without NewReader

Fixes #8126.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/103020044
»»»

TBR=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/105820043
@golang golang locked and limited conversation to collaborators Jun 25, 2016
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jun 25, 2018
Fixes golang#8126.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/103020044
This issue was closed.
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

3 participants