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.

Deep recursion / stackoverflow with tiff image

See original GitHub issue

Hello.

Tiff image can be downloaded here: https://github.com/cgohlke/imagecodecs/blob/master/tests/tiff/gray.movie.u2.tif

Then try to extract metadata by using this code:

InputStream inputStream = new ByteArrayInputStream(imageBlob);

Metadata metadata = ImageMetadataReader.readMetadata(inputStream);

Directory mimeTypeDir = metadata.getFirstDirectoryOfType(FileTypeDirectory.class);

String mimeType = mimeTypeDir.getString(3);
String extension = mimeTypeDir.getString(4);

This should throw a java.lang.StackOverflowError

I also tried using a a tool like ExifTool and it threw a similar warning: Deep recursion on subroutine "Image::ExifTool::ProcessDirectory" Deep recursion on subroutine "Image::ExifTool::Exif::ProcessExif"

Let me know if you need more details.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kaiwintercommented, Jun 1, 2022

Those tags are all in different IFDs. Please ignore my previous comment as I wasn’t aware of the exact TIFF structure but now I read some of the specification. I used a different tool to examine the structure of that tiff. It contains 65568 IFDs which is just too much for the default stack size. As the processing works in a recursive way this is just some kind of limitation.

@eriken You can work around this StackOverflowError by setting a bigger stack size for the VM e.g. -Xss1g. With that size I’m able to parse the TIFF using metadata-extractor.

1reaction
cgohlkecommented, Feb 4, 2022

Not sure this is helpful: the file gray.movie.u2.tif contains more than 2^16 IFDs. Such files are not uncommon in bio-imaging. Some libraries (e.g. libtiff) can not access all IFDs because they use an uint16 counter.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to prevent maximum recursion runtime error in python ...
I tried to run my code in PyCharm, with python 2.7.15 and libtiff 0.4.2. I put the block with the TIFF.open statement in...
Read more >
How to recursively and automatically convert all TIFs to an ...
I'm attempting to use GraphicsMagick in Ubuntu to convert hundreds of directories that contain multiple TIF files into one multi-page PDF ...
Read more >
Stack overflow - Wikipedia
In software, a stack overflow occurs if the call stack pointer exceeds the stack bound. ... cause of stack overflow is excessively deep...
Read more >
stack() in R does not include all .tiff files in my directory
In your code example evi <- list.files(files.evi, pattern = glob2rx("*MYD13Q1*.tif$"), full.names = TRUE). in the part after "pattern = .
Read more >
Available CRAN Packages By Date of Publication
2022-12-03, endogeneity, Recursive Two-Stage Models to Address Endogeneity. 2022-12-03, ExpImage, Tool For Analysis of Images in Experiments.
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