Skip to content

BUG: PNG IO fails on corrupt file#2942

Merged
dzenanz merged 1 commit intoInsightSoftwareConsortium:masterfrom
issakomi:pngio
Dec 20, 2021
Merged

BUG: PNG IO fails on corrupt file#2942
dzenanz merged 1 commit intoInsightSoftwareConsortium:masterfrom
issakomi:pngio

Conversation

@issakomi
Copy link
Copy Markdown
Member

@issakomi issakomi commented Dec 12, 2021

S. explanation and link to sample file in the post #2928 (comment)

Also this post is related #2933 (comment)

@github-actions github-actions Bot added area:IO Issues affecting the IO module type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances labels Dec 12, 2021
@issakomi issakomi changed the title BUG: PNG fails on corrupt file BUG: PNG IO fails on corrupt file Dec 12, 2021
@jhlegarreta
Copy link
Copy Markdown
Member

jhlegarreta commented Dec 12, 2021

💯 To this effort @issakomi.

Cross-referencing comments
#2933 (comment)
#2933 (comment)
#2933 (comment)

so that corrupted test files are added, and the degenerate situations they trigger are tested.

@issakomi
Copy link
Copy Markdown
Member Author

issakomi commented Dec 13, 2021

Cross-referencing comments

Not sure what i could answer here, here are no new "warning" trigger points, no changes in debug output, etc.
Just fixed setjmp wrapping and added one jump point in ReadImageInformation to avoid crash with corrupted example file.

I am afraid i have no more time, already spent 4 full days with bugs in JPEG and PNG IOs.
Consider this as suggestion and feel free to do with the PR whatever you find correct, close, accept, modify. No problem.

cc @Hconk

@jhlegarreta
Copy link
Copy Markdown
Member

Just fixed setjmp wrapping and added one jump point in ReadImageInformation to avoid crash with corrupted example file.

I am afraid i have no more time, already spent 4 full days with bugs in JPEG and PNG IOs.
Consider this as suggestion and feel free to do with the PR whatever you find correct, close, accept, modify. No problem.

@issakomi I understand. Thanks for the effort. Can at least the corrupted, readable and corrupted, unreadable images used to test this be shared?

@Hconk
Copy link
Copy Markdown

Hconk commented Dec 13, 2021

Just fixed setjmp wrapping and added one jump point in ReadImageInformation to avoid crash with corrupted example file.

I am afraid i have no more time, already spent 4 full days with bugs in JPEG and PNG IOs.
Consider this as suggestion and feel free to do with the PR whatever you find correct, close, accept, modify. No problem.

@issakomi I understand. Thanks for the effort. Can at least the corrupted, readable and corrupted, unreadable images used to test this be shared?

You can get corrupted png image from here.
#2928 (comment)

@jhlegarreta
Copy link
Copy Markdown
Member

You can get corrupted png image from here.
#2928 (comment)

Thanks @Hconk. I will add it to the testing suite as time permits.

Copy link
Copy Markdown
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

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

LGTM. I guess we should wait until test(s) are added before merging.

@dzenanz
Copy link
Copy Markdown
Member

dzenanz commented Dec 15, 2021

Looks good to me. Why not add it as the second commit in your branch pngio? Then we could merge it, without waiting for Jon's follow-up with improvements.

@dzenanz
Copy link
Copy Markdown
Member

dzenanz commented Dec 15, 2021

Data addition document is not long. Web interface is the most convenient for uploading a small number of files.

@dzenanz
Copy link
Copy Markdown
Member

dzenanz commented Dec 15, 2021

There is also a visual guide.

@github-actions github-actions Bot added type:Data Changes to testing data type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct labels Dec 18, 2021
@github-actions github-actions Bot removed the type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct label Dec 18, 2021
@issakomi
Copy link
Copy Markdown
Member Author

issakomi commented Dec 18, 2021

I have used itkPNGImageIOTest3.cxx, it is already for corrupted files with ITK_TRY_EXPECT_EXCEPTION.

P.S. BTW, interesting, this old test file triggers jump at the only one point where setjmp was not ruined with wrapping.

@issakomi issakomi requested a review from dzenanz December 18, 2021 13:14
@issakomi
Copy link
Copy Markdown
Member Author

issakomi commented Dec 18, 2021

BTW, the fix is minimal. There are more question.
In Read function not 100% sure about std::unique_ptr, how the auto-deletion works during jump, it is not volatile (BTW, the setjmp point after that std::unique_ptr is not changed, so the PR doesn't change this behavior, just FYI). This pointer was a usual pointer in the past, than was turned into std::unique_ptr not so long ago. Probably there was a memory leak due to setjmp unlucky issues.
Do we want PNG print output or not? The empty ITK custom function (to suppress debug from the library) is set at the very end of the story. There is a lot of PNG debug output in tests log. It is not changed by the PR too.

Copy link
Copy Markdown
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

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

Keeping the current situation regarding the PNG error and warning messages is fine. I don't have a preference for making it more consistent by more or less messages.

@dzenanz dzenanz merged commit 31ce397 into InsightSoftwareConsortium:master Dec 20, 2021
@issakomi issakomi deleted the pngio branch December 20, 2021 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:IO Issues affecting the IO module type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Data Changes to testing data type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants