2019.10.01 18:01 "[Tiff] TIFF_IO_MAX too large for Windows XP", by David C. Partridge

2019.10.01 19:37 "Re: [Tiff] TIFF_IO_MAX too large for Windows XP", by Roger Leigh

On 01/10/2019 19:01, David C. Partridge wrote:

After a lot of digging I found out why my code wasn't working when run in Windows XP (It was working fine of Window 7 and up)

In tif_unix.c the read() and write() calls were using TIFF_IO_MAX to set the maximum buffer size. Unfortunately when they were called with a request to read a large file the requested number of bytes to read was 170,769,911 bytes which resulted in read() returning -1 with errno set to EINVAL.

For now I have changed the #define for TIFF_IO_MAX thus:

//#define TIFF_IO_MAX 2147483647U
#define TIFF_IO_MAX USHRT_MAX

which limits the request size to 65535.

Does anyone know what the actual limit was on Windows XP? If higher than 65535 I'd like to increase the defined limit.

Would the libtiff maintainers consider changing this to an appropriate smaller value?

Hi David,

Did you try building with tif_win32.c instead of tif_unix.c?

For the change you made, would this not have quite negative performance implications for platforms supporting rather larger sizes?  This rather small when individual images can be many gigabytes.

I can see some documented limits here: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-writefile (nNumberOfBytesToWrite).  Whether they apply for your case, I don't know.

If this was to be supported, I think it would need to be set within an XP-specific #ifdef so that all the other platforms continue to use the larger size.

However, without wanting to sound too negative, Windows XP is thoroughly obsolete at this point.  It's five major releases behind, completely unsupported for over five years, and I don't see and value in expending effort in supporting and maintaining it in 2019. Same for Vista, also unsupported now for two years.  Extended support for 7 ends in January. https://support.microsoft.com/en-us/help/13853/windows-lifecycle-fact-sheet has the current lifecycles dates. If you need to support it, that's quite fine if you want to modify libtiff locally for your own use, but I'm unsure sure of the greater value in having such changes incorporated generally, especially if they will negatively effect currently supported platforms.  However, I'm willing to be persuaded if there are good reasons.

Kind regards,

Roger