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

PSD image processing may cause unhandled panic #11

Closed
wants to merge 1 commit into from
Closed

PSD image processing may cause unhandled panic #11

wants to merge 1 commit into from

Conversation

steve-hellwege-wdc
Copy link
Contributor

[why]
Earlier made to fix panic is not complete and can end up reading closed channel.

[how]
Correctly handle compress processing to wait for sub processing to finish before closing error channel.

[testing]
Manual, use earlier psd images which caused panic/crash, observe no panic.

[why]
Earlier made to fix panic is not complete and can end up reading closed channel.

[how]
Correctly handle compress processing to wait for sub processing to finish before closing error channel.

[testing]
Manual, use earlier psd images which caused panic/crash, observe no panic.
@steve-hellwege-wdc
Copy link
Contributor Author

IMG_0247.psd.zip
See attached which demonstrates issue.

@oov
Copy link
Owner

oov commented Dec 2, 2020

Your test file seems cause unrelated error.

psd: invalid image resource signature

This error already fix in 47a4ad6.
I haven't encountered any panics around decoding, how do I test it?

@steve-hellwege-wdc
Copy link
Contributor Author

steve-hellwege-wdc commented Dec 2, 2020

We integrate this library into a server which is long running. If your tool or test exits after it sees the first decoding error, then you won't encounter the issue.
The issue occurs when there are multiple errors in the decoding. The decodePackBits exists because of an earlier error, but the processing goroutine is still running and encounters another error. This causes a write to the error channel which was previously closed. The solution waits until all goroutines are finished, and only closes the error channel when they are done.

Perhaps the new commit you made also fixes the issue as it now properly decodes because of the correct resource signature. However, the change is still valid as it ensures the goroutines are finished decoding before closing the error channel, which is clean.

@oov
Copy link
Owner

oov commented Dec 3, 2020

I understand for the validity of this PR.

But in the first place, I think #9 and #11 are heading in the wrong way for this issue.
I should have pointed to the right direction.
Sorry, it's my fault.

The package should not depend on panic because the encountering broken inputs is a normal situation.
So I reverted #9 and add some range checks in dad9002.

The problems caused by panic during decoding would now be solved.
If this doesn't solve for you, contact me again.

Thanks.

@oov oov closed this Dec 3, 2020
@steve-hellwege-wdc
Copy link
Contributor Author

Ok, yes thank you. Better to have input checks and avoid panics, then you don't need the panic processing. Will check this out.

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.

None yet

2 participants