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

image/png: panic in reader.go #19738

Closed
Deleplace opened this issue Mar 28, 2017 · 7 comments
Closed

image/png: panic in reader.go #19738

Deleplace opened this issue Mar 28, 2017 · 7 comments

Comments

@Deleplace
Copy link
Contributor

Deleplace commented Mar 28, 2017

Please answer these questions before submitting your issue. Thanks!

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

go version go1.8 linux/amd64

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/valentin/Documents/2017/03/21/goDLL"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build002149362=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

image.Decode(r2) where r2 is reading a PNG image that looks ok to me.
See attached source.
(texture1, r1 are there just to demonstrate the happy path).
See self-contained code at https://play.golang.org/p/gkXmcSjbwq

What did you expect to see?

At best, no error at all.
Otherwise, image.Decode should return an error with some nice message.

What did you see instead?

2017/03/28 13:58:41 Texture 1
2017/03/28 13:58:41 size = 737
2017/03/28 13:58:41 format = jpeg
2017/03/28 13:58:41 err = <nil>
2017/03/28 13:58:41 
2017/03/28 13:58:41 Texture 2
2017/03/28 13:58:41 size = 1031
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4a9d68]

goroutine 1 [running]:
image/png.(*decoder).readImagePass(0xc42002d800, 0x7f75cf6f4088, 0xc420018230, 0x0, 0xc420018200, 0x0, 0x0, 0xc420092000, 0xc42002d878)
	/usr/local/go/src/image/png/reader.go:615 +0x1028
image/png.(*decoder).decode(0xc42002d800, 0x0, 0x0, 0x0, 0x0)
	/usr/local/go/src/image/png/reader.go:365 +0x621
image/png.(*decoder).parseIDAT(0xc42002d800, 0x3c0, 0x4e6d5e, 0x4)
	/usr/local/go/src/image/png/reader.go:827 +0x36
image/png.(*decoder).parseChunk(0xc42002d800, 0x0, 0x0)
	/usr/local/go/src/image/png/reader.go:887 +0x45a
image/png.Decode(0x7f75cf6f4030, 0xc420014240, 0xc420014240, 0x7f75cf6f4030, 0xc420014240, 0x8)
	/usr/local/go/src/image/png/reader.go:946 +0x161
image.Decode(0x54f140, 0xc420016510, 0x407, 0xc420070900, 0x407, 0x480, 0x0, 0x0)
	/usr/local/go/src/image/format.go:84 +0xfc
main.main()
	/home/valentin/Documents/2017/03/28/tecrash/read.go:27 +0x677
exit status 2
@Deleplace
Copy link
Contributor Author

issue_19738_panics.zip

@Deleplace
Copy link
Contributor Author

Texture 2 may or may not contain some corrupt bytes.
texture2
It looks ok on my desktop and on GitHub.
And the real problem is in the png decoder panicking (I would be ok with just an error properly returned).

@dgryski
Copy link
Contributor

dgryski commented Mar 28, 2017

Does this fail on tip? It may be a duplicate of #19553

@odeke-em odeke-em changed the title panic in image/png/reader.go image/png: panic reader.go Mar 28, 2017
@odeke-em
Copy link
Member

@dgryski, good hunch. It doesn't panic anymore on tip 73912a1

$ go version && go run main.go && echo success
go version devel +73912a1 Mon Mar 27 18:41:30 2017 -0600 darwin/amd64
2017/03/28 09:30:29 Texture 1
2017/03/28 09:30:29 size = 737
2017/03/28 09:30:29 format = jpeg
2017/03/28 09:30:29 err = <nil>
2017/03/28 09:30:29 
2017/03/28 09:30:29 Texture 2
2017/03/28 09:30:29 size = 1031
2017/03/28 09:30:29 format = png
2017/03/28 09:30:29 err = <nil>
success

@Deleplace please get the latest from the master branch.

@odeke-em
Copy link
Member

Can't reproduce on the latest. Please reopen if it persists.

@odeke-em odeke-em changed the title image/png: panic reader.go image/png: panic in reader.go Mar 28, 2017
@Deleplace
Copy link
Contributor Author

Thanks! I had performed a quick search for "png decode" in issues, but for some reason I had not seen #19553. It looks the same, I will try on tip.

@Deleplace
Copy link
Contributor Author

Not reproduced on recent 4b50c81 . Great!

@golang golang locked and limited conversation to collaborators Mar 28, 2018
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