Created attachment 20336 [details] PDF file When converting the attached PDF file to color TIFF or JPEG (tried it with tiff24nc and jpeg devices) only the first 12 pages are converted and gs exits with no error message. When converting to monochrome tiff (tiffg4) everything works just fine. It also works if I convert the PDF to PDF with pdfwrite device. I tried it with gs9.53 and gs master and got the same results. Everything works fine in gs9.08.
Created attachment 20337 [details] Simplifies sample file This is a simplified and decompressed version of the sample file. Debug build of Ghostscript shows the following error: GPL Ghostscript GIT PRERELEASE 9.54.0: ./base/gxclrast.c(1065): bitmap size exceeds buffer! width=1920 raster=5760 height=1 file pos 202745 buf pos 45/4096 The file runs to completion with -dNOINTERPOLATE option.
Since this seems to be clist related, I'll take it. :-(
I cannot reproduce this error with: -sDEVICE=tiff24nc -o Bug703245.tif Bug703245.pdf (or with -sDEVICE=jpeg) I've attached the output I get from the tiff24nc file. Note the debugbin build does not produce any errors or warnings as Peter mentioned. Tested with 9.53.3 and with current HEAD.
Created attachment 20532 [details] Bug703245.tif Output from HEAD (commit 5bbb4c7) with: -sDEVICE=tiff24nc -o Bug703245.tif -Z: -sCompression=lzw Bug703245.pdf
Ray, I can reproduce the problem on Windows and on Linux, in debug and release builds, with the original and with the simplified files. Please retest.
I tried this as well for another data point. For me, on Linux using the current HEAD (SHA c23d68c1e8da7a4e4134b143f147427092b3d2f2) and this command line: gs -sDEVICE=tiff24nc -o out.tif 12.pdf the debug build gives a debug message before failing with an error: GPL Ghostscript GIT PRERELEASE 9.54.0: ./base/gxclrast.c(1069): bitmap size exceeds buffer! width=1920 raster=5760 height=1 file pos 202745 buf pos 45/4096 Error: /ioerror in --showpage-- A release build crashes with a floating point exception and dumps core. On Windows, 64-bit build using VS 2008, the behaviour of the debug build is identical with that on Linux. A release build does produce a TIFF file without any errors or warnings, but the content is garbage. On Windows, using this command line: gswin64c -sDEVICE=jpeg -o out.jpg 12.pdf the debug build issues the same warning as the tiff24nc device, but both the release and debug builds continue to completion and produce apparently correct JPEG output. On Linux the command line gs -sDEVICE=jpeg -o out.jpg 12.pdf and a debug build produces the same warning but emits an apparently correct JPEG file. The release build still crashes with a floating point exception. Note that I have *only* used Peter's simplified single page file, not the original file supplied by Mike. As Peter noted, setting -dNOINTERPOLATE resolves the problem as well.
Still having inconsistent results attempting to reproduce on Win 64 or 32 builds. Since it is inconsistent, trying a valgrind build.
Traced thus far (after interruptions) to colorspace interactions (yet more??) with the pdf14 compositor. The data written for the copy_color is small enough for the buffer size because it is calculated with a color depth of 8 bits. When reading (for this band) the depth is 24 bits, which would not fit if the width > 1360 (in this case the width is 1920).
Fixed by commit 331fcb49b62a615976711cccdd3ff9796152a323 The pdf14 compositor changes the color depth to 8 for a SMask, but the compositor actions were not being put in all the bands needed. In this case the copy_color_alpha was output from the interpolation logic because the image gridfitting expanded the image. Fix it by expanding the top and bottom limits for the "temp_cropping" which controls the RECT loop writing the compositor info to the bands.
Assuming the customer is notified, since the customer submitted the bug. The patch is: diff --git a/base/gxclimag.c b/base/gxclimag.c index 8d39831..4e21b55 100644 --- a/base/gxclimag.c +++ b/base/gxclimag.c @@ -1376,6 +1376,11 @@ clist_create_compositor(gx_device * dev, temp_cropping_min = cdev->cropping_min; temp_cropping_max = cdev->cropping_max; } + /* Adjust the lower and upper bound to allow for image gridfitting changing boundaries */ + if (temp_cropping_min > 0) + temp_cropping_min--; + if (temp_cropping_max < dev->height - 1) + temp_cropping_max++; if (temp_cropping_min < temp_cropping_max) { /* The pdf14 compositor could be applied only to bands covered by the pcte->params.bbox. */