Opening corrupt Aperio SVS file causes Out-of-Memory error
See original GitHub issueHi @cgohlke
I encountered a corrupted AperioSVS file that causes a machine with 64GB of ram to run out-of-memory when trying to instantiate the TiffFile instance. Creating the instance causes a dramatic increase in process memory usage in the TiffTag loading part of tifffile, which just causes the server to kill the python process. Ideally I would expect the code to just crash early, so that cleanup can happen in python.
Sadly I can’t share the file, so here’s some additional information:
The filesize is 5958078846 bytes and it’s recognized as TIFF.CLASSIC_LE
tifffile detects tagno=3126
tags, of which almost all raise an unknown tag data type error.
Then for tag tagno=2327 it calls TiffTag.from_file
with offset=3256275384
and header=b'\x01\x00\x02\x00\x00?\x00\xeb5\x05\x92\x1b'
Which due to the large count
causes a ~4.000.000 character string to be unpacked later in this code path and due to some string ops causes a massive increase in Memory consumption.
I was wondering if there are upper bounds on the amount of data a TiffTag can contain, and this codepath could error early.
Cheers, Andreas 😃
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (5 by maintainers)
Top GitHub Comments
Should be mitigated by v2021.11.2, which delay-loads non-essential TIFF tag values.
Tested with all corrupted files that were problematic and it works perfectly now. Thank you so much!