-
Notifications
You must be signed in to change notification settings - Fork 119
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
Overflow Exception in MakeBigTIFF #40
Comments
I was able to create a simple unit test to reproduce the problem. In the attached zip, there are two files. Add BigTiff.cs to the UnitTests project and copy the tiff file to the TestCase folder. I suspect that the problem may be in adding a non-bigtiff image as a page to the bigtiff image. The problematic code seems to be called in that case. |
Hello! Thank you for the detailed bug report and the test code. Unfortunately, we are very busy right now so we won't be able to take a look at it in the next few days. |
I wanted to let you know that I've found a workaround that I can use for now. If I open my output tiffs as BigTiffs, regardless of their size, I don't hit this bug. For example: I'm still interested in the fix for the underlying issue, and I'd be happy to help out in any way possible. Thanks! |
Hello, I converted your test code to C++ and checked it with libtiff 4.0.7 (latest version of the original library). The code fails with So, for now I see two options:
The first option will make the library more explicit in case of an error but you will still need to use your workaround. The second option will probably require more work and I am not sure we will find time for it. Please let me know if you see an other option. Here is the code I used:
|
Thanks for following up. I think given the constraints on time available to fix the issue, it would be totally acceptable to mirror the behavior of libtiff, and throw an exception with a descriptive message. |
I'm using your library to create very large tiffs from stitched microscopy images. Your code has been working great! I really appreciate this project! I recently ran into a problem that I've been unable to figure out a solution for. When writing the output for one particularly large scan, I'm running into an Overflow Exception in MakeBigTiff.
For this problematic scan, the details are that I'm writing out a 81,920 x 57,344 tiled tiff. (16bit, single channel) I then create a second tiled tiff that's 40,960 x 28672. I open the larger tiff in "a" mode and add the second image as a page by copying one tile at a time. After all of the tiles have been copied, as the tiff objects are disposed, the exception occurs in the MakeBigTiff method. This code has been working fine now with many other smaller files.
I've stepped through the source code for MakeBigTiff a few times, but so far I'm unable to identify exactly what the issue is. I've had a tough time following the intended logic in this method. I see at least a couple of places where values appear to be read into variables that are too small to hold them. I'm unsure though if some of this is intentional.
I made one attempt at creating a unit test that could reproduce the issue. That first attempt didn't trigger the exception, but it did create a tiff file that couldn't be opened. I'm going to try another attempt using the same exact dimensions as the problematic image - I'll update this ticket with that test, if it works.
Here's the exception text:
System.OverflowException occurred
HResult=-2146233066
Message=Arithmetic operation resulted in an overflow.
Source=BitMiracle.LibTiff.NET40
StackTrace:
at BitMiracle.LibTiff.Classic.Tiff.MakeBigTIFF() in C:\Root\GitHub\Repos\libtiff.net\LibTiff\Internal\Tiff_DirWrite.cs:line 490
InnerException:
The text was updated successfully, but these errors were encountered: