nfnt / resize

Pure golang image resizing
ISC License
3.02k stars 321 forks source link

Panic on Resize #52

Closed dominikschulz closed 6 years ago

dominikschulz commented 8 years ago

Hi,

we get this issue when resizing some user-supplied pictures.

And no, unfortunately I can't provide any sample pics. I'll try to get one.

goroutine 5456 [running]:
panic(0xc34040, 0xc42000c0c0)
        /usr/local/go/src/runtime/panic.go:500 +0x1a1
github.com/nfnt/resize.resizeRGBA(0xc4203e4c40, 0xc4203e58c0, 0x0, 0xc422c18000, 0x1944, 0x1944, 0x
        github.com/nfnt/resize/converter.go:119 +0x44d
github.com/nfnt/resize.Resize.func2(0xc420610140, 0xc4203e4c40, 0xc4203e58c0, 0x0, 0xc4205900a0, 0x
        github.com/nfnt/resize/resize.go:130 +0xc5
created by github.com/nfnt/resize.Resize
       github.com/nfnt/resize/resize.go:131 +0x345b
unixpickle commented 8 years ago

Could you post the actual panic message in addition to the backtrace you supplied?

dominikschulz commented 8 years ago

Sorry, forgot to include that one. It was an panic: runtime error: index out of range.

Besides the fact that this should not happen, it's also impossible (?) to catch with recover since the Code is running in it's own goroutine.

nfnt commented 8 years ago

Hard to say without a sample, because (in theory) this shouldn't happen. Unfortunately it's not possible to avoid this in code, by e.g. using for range, without losing a lot of performance.

dominikschulz commented 8 years ago

We are trying to isolate some good test cases, but it's a lot of work given the number of candidate images we have. Will report back if we are able to narrow this down.

For our use case it would be preferable to sacrifice some performance for reliability.

unixpickle commented 7 years ago

I recently ran into this bug myself. It was caused because I was resizing 0x0 images with bilinear interpolation.

dominikschulz commented 7 years ago

We found some way to isolate some useable testcases, but I'm really busy the next few weeks. I'll try to provide some samples anytime soon.