Using tiffsep device with specific PageSizes and resolutions leads to Crash or rangecheck error. Consider following PS code: << /PageSize [1670 1158] >> setpagedevice .5 setgray clippath fill showpage Set resolution to 1200x1200 DPI (-r1200x1200) and -sDEVICE=tiffsep Result: In gs-HEAD you get a rangecheck error in showpage. Pre-Head, like 8.54: CRASH in mem_true64_fill_rectangle() (at the very beginning) while filling rectangle. I guess, only one band of memory should be erased at this time, but the coordinates are set for the whole image (in this case: very big). Vary the PageSize parameters or resolution a little and it works! This makes me unhappy, because depending on the size of input document, GS fails.
I've verified that this occurs with gshead and tiffsep but not with the bmpsep1 or bmpsep8 devices, so am assigning it accordingly.
The tiffsep device (like the tiff32nc and tiff24nc devices) creates uncompressed tiff image files. TIFF is an older format and does not support 64 bit values for offsets and lengths, so this PageSize is too large to fit at 1200 dpi. This PageSize works out to be 2148707600 bytes which is too large. To handle larger page sizes, the TIFF would have to use compression, which is an enhancement.
I think TIFF has unsigned offsets and should support about 4GB of data. We hit 2GB limit because we use old file access functions.
What exactly is needed to collect on this? Tiff compression? Ensure the use of unsigned values for offsets and the like? Both? Neither? ☺
Today’s master (64bit lang switch build) finishes that ps w/o error. The plate tiffs are LZW compressed. The combined tiff is not. I haven’t tested a 32 bit compile, but at least for 64 bit compiles this seems fixed?
Created attachment 7705 [details] Patch for bug 689781
The composite TIFF with the given page size and resolution happens to be between 2GB and 4GB. Submitted a patch to fix this.
Created attachment 7710 [details] Regenerated patch for 689781
I'm not sure how it could happen, but if the file size ever exceeded 0xffffffff then the truncation of 0xffffffff - gp_ftell_64 would give an incorrect result with the patch in comment 8. To be totally sure, a separate check for int64_t file size > 0xffffffff should be included to trigger the rangecheck.
Created attachment 7711 [details] Patch for 689781 Revision 2 Can not reproduce the error on Windows as described in comment 9 (getting "range check" error as expected for 2400 dpi). But submitted a revised patch.
Ghostscript uses libTiff now, which handles files that exceed 2GB correctly. libTiff also detects when TIFF file exceeds 4GB and propagates this condition to PostScript level. Everything seems to work just fine now.