question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hangs in JPEGSegmentImageInputStream with bad data

See original GitHub issue

My 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:closed
  • Created 4 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
marcreichmancommented, Dec 19, 2019

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!

1reaction
marcreichmancommented, Dec 10, 2019

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ImageIO.createImageInputStream - Java - Tabnine
getResourceAsStream("/jpeg/exif-rgb-thumbnail-bad-exif-kodak-dc210.jpg")); try ... data); inputStream.close(); File outputDirectory = Files.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found