Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@MichaHoffmann
Copy link
Member

@MichaHoffmann MichaHoffmann commented Jul 9, 2022

The test image crashed on my perkeep instance with

Jul 09 12:14:01 ubuntu perkeepd[74240]: 2022/07/09 12:14:01 Retrying with jpeg.Decode, because djpeg failed with: exit status 2: Invalid SOS parameters for sequential JPEG
Jul 09 12:14:02 ubuntu perkeepd[74240]: 2022/07/09 12:14:02 http: panic serving 192.168.178.38:44074: runtime error: invalid memory address or nil pointer dereference
Jul 09 12:14:02 ubuntu perkeepd[74240]: goroutine 7711129 [running]:
Jul 09 12:14:02 ubuntu perkeepd[74240]: net/http.(*conn).serve.func1(0x4020f57e00)
Jul 09 12:14:02 ubuntu perkeepd[74240]:         /home/micha/.local/go/src/net/http/server.go:1802 +0xe4
Jul 09 12:14:02 ubuntu perkeepd[74240]: panic({0xea4340, 0x203d300})
Jul 09 12:14:02 ubuntu perkeepd[74240]:         /home/micha/.local/go/src/runtime/panic.go:1052 +0x2b4
Jul 09 12:14:02 ubuntu perkeepd[74240]: perkeep.org/internal/images.rescale({0x0, 0x0}, 0x620, 0x3e8)
Jul 09 12:14:02 ubuntu perkeepd[74240]:         /home/micha/git/perkeep.org/internal/images/images.go:311 +0x20
Jul 09 12:14:02 ubuntu perkeepd[74240]: perkeep.org/internal/images.decode({0x1648da0, 0x402cee99e0}, 0x4018765360, 0x0)
Jul 09 12:14:02 ubuntu perkeepd[74240]:         /home/micha/git/perkeep.org/internal/images/images.go:505 +0x748
Jul 09 12:14:02 ubuntu perkeepd[74240]: perkeep.org/internal/images.Decode({0x1648da0, 0x402cee98c0}, 0x4018765360)
Jul 09 12:14:02 ubuntu perkeepd[74240]:         /home/micha/git/perkeep.org/internal/images/images.go:596 +0x2ac
Jul 09 12:14:02 ubuntu perkeepd[74240]: perkeep.org/pkg/server.(*ImageHandler).scaleImage(0x4018765758, {0x166c110, 0x4019518a80}, {{0x167a6d8, 0x401fd97a40}})
Jul 09 12:14:02 ubuntu perkeepd[74240]:         /home/micha/git/perkeep.org/pkg/server/image.go:297 +0x2e4
Jul 09 12:14:02 ubuntu perkeepd[74240]: perkeep.org/pkg/server.(*ImageHandler).ServeHTTP.func1()
Jul 09 12:14:02 ubuntu perkeepd[74240]:         /home/micha/git/perkeep.org/pkg/server/image.go:383 +0x48

because error during fallback decoding was not handled properly.

Furthermore status code 2 for djpeg just means warning, the output is still usable ( at least in my experiments it produced good results )

@MichaHoffmann MichaHoffmann force-pushed the mhoffm-fix-error-handling-in-image-decoding branch 2 times, most recently from 1f58efc to 824b779 Compare July 10, 2022 18:41
@MichaHoffmann
Copy link
Member Author

without the patch:
image

with the patch:
image

cmd.Stderr = stderrW
if err := cmd.Run(); err != nil {
// if djpeg finished with warnings ( exit code 2 )
// the output is still usable most of the time
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't you at least look at the w bytes.Buffer to see if it was written to and is the expected size?

@MichaHoffmann MichaHoffmann force-pushed the mhoffm-fix-error-handling-in-image-decoding branch 2 times, most recently from 2295dd1 to 9cb03d6 Compare July 10, 2022 20:33
@MichaHoffmann MichaHoffmann force-pushed the mhoffm-fix-error-handling-in-image-decoding branch from 9cb03d6 to 06661fe Compare July 10, 2022 20:37
@bradfitz bradfitz merged commit d974afa into perkeep:master Jul 10, 2022
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 this pull request may close these issues.

2 participants