Skip to content

tiffload: add support for unlimited flag, requires libtiff 4.7.0+ #4322

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

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

lovell
Copy link
Member

@lovell lovell commented Dec 19, 2024

Adds a default limit of 20MB for total maximum ("cumulated") memory allocation during tag processing, which should be enough for hundreds if not thousands of tags. I could easily be persuaded to reduce this default limit.

Given libtiff is rather over-zealous in the number of times it reallocates memory, an image containing many thousands of tags can quickly lead to fragmentation. Attempting to process the <1MB sample image at https://issues.oss-fuzz.com/issues/42531230 with this memory limitation in place still results in an RSS of ~1GB (the OSS Fuzz issue should auto-close after this PR is merged).

Builds on #4313 and implements #3892 for inclusion in 8.17.

Default limit for cumulative allocation to 20MB, which is enough
for hundreds of tags.

Due to the way libtiff likes to re-allocate memory, an image
with thousands of tags can quickly lead to fragmentation.
@jcupitt jcupitt merged commit dee0d89 into libvips:master Dec 19, 2024
6 checks passed
@jcupitt
Copy link
Member

jcupitt commented Dec 19, 2024

Great! Let's leave the 20mb for now, we can always tune this later.

@lovell lovell deleted the tiffload-unlimited branch December 20, 2024 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants