Hangs in JPEGSegmentImageInputStream with bad data
See original GitHub issueMy project uses TwelveMonkeys (attempted the last 2 releases) to convert images into normalized formats (e.g. anything -> rgb jpeg) for later processing. We’ve encountered scenarios where junky data has hung while inside the ImageIO.read
or the ImageReader.getImageTypes
methods and never return. The major annoyance with this situation is that the input data is in a secure customer site and I do not even have access to it personally. Please note, these files are NOT usable, they don’t work in browsers, windows paint, etc. I am not looking for a functioning load with them, but just for them not to hang. Without the TM library in classpath they simply do not load correctly with the default ImageIO paths but they don’t hang.
I have put together an image testing harness using some similar code, and was able to get a trace of the threads at hang time. This is what is enabling me to write this ticket; unfortunately providing the actual input files is NOT going to be an option. I’m happy to provide this tester harness if you’d like, but again I can’t provide the files.
This is the trace as I can provide it:
JPEGSegmentImageInputStream 279
JPEGSegmentImageInputStream 179
JPEGSegmentImageInputStream 387
JPEGSegmentImageInputStream 423
JPEGImageReader 312
JPEGImageReader 609
JPEGImageReader 347
JPEGImageReader 481
JPEGImageReader 602
JPEGImageReader 783
JPEGImageReader 773
JPEGImageReader 227
<my code>
ImageUtils 133
ImageUtils 61
Without the TM libraries loaded, the failure from the default ImageIO is an IOException
with Invalid JPEG file structure: two SOF markers
. This doesn’t hang, just returns errors.
Happy to help with more info if necessary. Typically this has been tested with JDK 8u171, Linux x64 and Windows x64.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (5 by maintainers)
Top GitHub Comments
Hi Harald!
Thanks for your patience. Your suggested fix does indeed eliminate the hang, so nice work on finding that given no input data! We are still working on identifying if there are obvious patterns in the header data, using a copy of
jpegdump
. I’ll let you know if we find anything useful.Thanks again for this library and for your help with this issue!
Thanks for the feedback and ideas. I’ll have to do some digging and see what we can do and get back to you.
Really appreciate the help and the library!