-
Notifications
You must be signed in to change notification settings - Fork 8
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
fix: Detect corrupted files, exit on exception (DEV-4457) #459
Conversation
86469df
to
e02685a
Compare
e02685a
to
6ad6dc5
Compare
src/sipi.cpp
Outdated
@@ -862,6 +862,7 @@ int main(int argc, char *argv[]) | |||
} | |||
} catch (Sipi::SipiImageError &err) { | |||
std::cerr << err << std::endl; | |||
exit(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, does that mean that in the past, all SipiImageError
resulted in return code 0, but now, they will all result in return code 1?
That would not be the expected behaviour. Because often, an image is only slightly corrupted, but perfectly readable by most viewers. For example, the ca. 66'000 images of LHTT produced ca. 14'000 error logs. But most of them are negligible, because there is no real defect in the image. We'd like that SIPI only aborts with non-0 in these very specific cases:
Corrupt JPEG data: premature end of data segment
(https://linear.app/dasch/issue/DEV-4480)Corrupt JPEG data: bad Huffman code
(https://linear.app/dasch/issue/DEV-4457)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very odd, but it was also my intention to check whether this new behavior breaks the build. Unfortunately the main
build is broken. 🤦
Anyhow, I'll restrict it to the behavior you've described.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in the last commit, after I resolved the build issues in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@siers In this notion page, we discussed that we should probably not modify the SIPI behaviour at all -> https://www.notion.so/SIPI-error-logs-1748946b7d4080618e91cf0527b9d7a7?d=1748946b7d408031a344001cf88f05f8&pvs=4#1748946b7d408058825ac23f05bcfc38
Have you seen the discussion there?
Sorry that this comes only now, after you have already invested time. We should have spent more time on thinking about the issue, before creating a Linear ticket.
I suggest that you don't spend any more time on this PR, before we have decided what to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I missed that. Don't worry, the hardest part was fixing the build and we needed to do that anyway.
6ad6dc5
to
d1693c6
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files
|
This corruption warning is non-fatal, so we have to check if the error code is set to a specific JWRN after jpeg_read_scanlines. Test added that an exception is created in img.read.
References:
https://github.com/mozilla/mozjpeg/blob/6c9f0897afa1c2738d7222a0a9ab49e8b536a267/jerror.h#L195
https://github.com/mozilla/mozjpeg/blob/6c9f0897afa1c2738d7222a0a9ab49e8b536a267/jerror.h#L280-L283
https://github.com/mozilla/mozjpeg/blob/6c9f0897afa1c2738d7222a0a9ab49e8b536a267/jdphuff.c#L551-L552
https://github.com/mozilla/mozjpeg/blob/6c9f0897afa1c2738d7222a0a9ab49e8b536a267/jdhuff.c#L463-L466