issue1: We encountered a segmentation fault while trying to process some pdf files with ghostscript while Acrobat Reader shows them fine. we fixed the warnings with no success. we splitted the multipage pdf to single pages and it worked ok for every page individually. Files can be located at: http://dev.innews.gr/pdf_tiff/forps/ghostscript/multipdf2.tar.gz issue2: During the debugging proccess we created some pdfs with single images (background/foreground+mask for foreground) and for some images it worked while for others we got a segmentation fault. Compressed and decompressed versions of a failing file can be found at: http://dev.innews.gr/pdf_tiff/forps/ghostscript/notworking.tar.gz Converting the page to A4 dimensions seem to fix the problem. we are not sure if issue1 and issue2 are related however we found the following that seems to be a bug: gdevpdfb.c:421 (for_pattern < 2 || nbytes < 512000 ? (code = psdf_setup_lossless_filters((gx_device_psdf *) pdev, &piw->binary[0], (gs_pixel_image_t *)pim, false)) : (code = psdf_setup_image_filters((gx_device_psdf *) pdev, &piw->binary[0], (gs_pixel_image_t *)pim, NULL, NULL, false, false)) in our case, for one image that worked nbytes was < 512000 and for notworking.pdf nbytes was > 512000 in which case we go to gdevpsdi.c:502 int psdf_setup_image_filters(gx_device_psdf * pdev, psdf_binary_writer * pbw, gs_pixel_image_t * pim, const gs_matrix * pctm, const gs_imager_state * pis, bool lossless, bool in_line) notice that lossless is false and pis is NULL because of the call gdevpsdi.c:614 setup_image_compression(pbw, ¶ms, pim, pis, lossless); gdevpsdi.c:330 code = choose_DCT_params((gx_device *)pbw->dev, pcs, pis, &list, ¶m, st); gdevpsdi.c:149 convert_color((gx_device *)&mdev, pcs, pis, &cc, c[3]); gdevpsdi.c:104 code = pcs->type->remap_color(cc, pcs, &dc, pis, pdev, gs_color_select_texture); gxcmap.c:758 gx_remap_concrete_rgb(fred, fgreen, fblue, pdc, pis, dev, select); which is a macro defined as: ((pis)->cmap_procs->map_rgb)(cr, cg, cb, pdc, pis, dev, select) but pis is NULL so we get a segmentation fault
I'm not able to find any problems with the files in the notworking.tar archive, but I can reproduce a problem with the file multipdf2_mp.pdf: marcos@macbookpro:[39]% gshead -sDEVICE=tiff24nc -o test%d.tif ./multipdf2_mp.pdf GPL Ghostscript SVN PRE-RELEASE 8.65 (2009-02-04) Copyright (C) 2009 Artifex Software, Inc. All rights reserved. This software comes with NO WARRANTY: see the file PUBLIC for details. Processing pages 1 through 44. Page 1 Loading NimbusSanL-Regu font from %rom%Resource/Font/NimbusSanL-Regu... 2930964 1098159 11710988 10303474 3 done. Page 2 ../gshead: line 1: 52847 Segmentation fault ~/artifex/ghostscript/gs/bin/gs - I/Users/marcos/artifex/ghostscript/gs/lib -I/Users/marcos/artifex/fonts -dNOPAUSE -dBATCH $* marcos@macbookpro:[40]%
Created attachment 4814 [details] multipdf2_mp.pdf
Created attachment 4815 [details] multipdf2_mp_simplified.pdf Simplified version of the original file (attempts to remove any remaining elements using Acrobat 9.0 results in file that is readable by Ghostscript).
we confirm that files in notworking.tar do not fail on a clean system root@thbux:~/agis# ghostscript -sDEVICE=pswrite -sOutputFile=a.ps -sNOPAUSE -sBATCH notworking.pdf GPL Ghostscript 8.63 (2008-08-01) Copyright (C) 2008 Artifex Software, Inc. All rights reserved. This software comes with NO WARRANTY: see the file PUBLIC for details. Processing pages 1 through 1. Page 1 However they do fail on our initial system: root@dev:~/agis/pdfcreator/forps/ghostscript# ghostscript -sNOPAUSE -sBATCH notworking.pdf GPL Ghostscript 8.63 (2008-08-01) Copyright (C) 2008 Artifex Software, Inc. All rights reserved. This software comes with NO WARRANTY: see the file PUBLIC for details. Processing pages 1 through 1. Page 1 Segmentation fault What could differ from one system to an other? root@thbux:~/agis# cat /proc/version Linux version 2.6.26-5-generic (buildd@crested) (gcc version 4.3.1 (Ubuntu 4.3.1-9ubuntu1) ) #1 SMP Fri Aug 15 13:54:22 UTC 2008 root@thbux:~/agis# cat /proc/cpuinfo | grep "model name" model name : AMD Athlon(tm) 64 X2 Dual Core Processor 4400+ model name : AMD Athlon(tm) 64 X2 Dual Core Processor 4400+ root@dev:~/agis/pdfcreator/forps/ghostscript# cat /proc/version Linux version 2.6.17-12-generic (root@king) (gcc version 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)) #2 SMP Tue Feb 12 00:40:49 UTC 2008 (Ubuntu 2.6.17-12.44-generic) root@dev:~/agis/pdfcreator/forps/ghostscript# cat /proc/cpuinfo | grep "model name" model name : AMD Athlon(tm) 64 X2 Dual Core Processor 3800+ model name : AMD Athlon(tm) 64 X2 Dual Core Processor 3800+
reinstalling ghostscript corrected the problem with notworking.pdf in both systems. But our main concern is multipdf2_mp.pdf.
I rushed to confirm notworking was OK. Using -sDEVICE=ps2write instead of -sDEVICE=pswrite as we were using during debugging we get the segmentation fault on both linux systems and a windows workstation. Nevertheless files like multipdf2_mp.pdf are our primary concern and multipdf2_mp_simplified.pdf fails in our systems too. Using any program to preprocess the pdf would be great for our purpose. Our current solution is to replace the masked images with non-masked DCTencoded ones which work without problems but result in *10 file size. root@dev:~/agis/pdfcreator/forps/ghostscript# ghostscript -sDEVICE=ps2write -sOutputFile=a.ps -sNOPAUSE -sBATCH notworking.pdf GPL Ghostscript 8.63 (2008-08-01) Copyright (C) 2008 Artifex Software, Inc. All rights reserved. This software comes with NO WARRANTY: see the file PUBLIC for details. Processing pages 1 through 1. Page 1 Segmentation fault root@dev:~/agis/pdfcreator/forps/ghostscript# root@thbux:~/agis# ghostscript -sDEVICE=ps2write -sOutputFile=a.ps -sNOPAUSE -sBATCH notworking.pdf GPL Ghostscript 8.63 (2008-08-01) Copyright (C) 2008 Artifex Software, Inc. All rights reserved. This software comes with NO WARRANTY: see the file PUBLIC for details. Processing pages 1 through 1. Page 1 Segmentation fault root@thbux:~/agis# C:\Documents and Settings\agis\Desktop\notworking>"c:\Program Files\gs\gs8.63\b n\gswin32c.exe" -sDEVICE=ps2write -sOutputFile=test.ps notworking.pdf GPL Ghostscript 8.63 (2008-08-01) Copyright (C) 2008 Artifex Software, Inc. All rights reserved. This software comes with NO WARRANTY: see the file PUBLIC for details. Processing pages 1 through 1. Page 1 ["this program has encountered an error an needs to close" dialog]
Created attachment 4817 [details] testcase.tar.gz a further simplified version of multipdf2_mp_simplified.pdf that fails (out.pdf_simplified2.pdf) along with one with the same content (different compression/dict-entries) that succeeds (out.pdf_simplified.pdf).
Thank you for your time (and patience if you read my lengthy comments...). It seems that the problem in multipdf2_mp.pdf (and testcase.tar.gz) is in the JBIG2Encode software we used (http://www.imperialviolet.org/jbig2.html) and somehow Acrobat bypasses it. Files also fail when moving them directly in a Xerox/Sun printer hot folder. It is strange though that the same images with the same encoding work if pdf is splitted to one page per file. Knowing the exact encoding error and splitting corrects the problem would be interesting but in any case we solved our problem by decoding the mask using jbig2dec and then flate encoding it. It would also be interesting to know why decompressed files in notworking.tar.gz fail when -sDEVICE ps2write is used instead of -sDEVICE pswrite or tiff24nc. Finally it is probably an error in usage but it would be interesting to know why when using ghostscript on a linux system through ssh and without an -sDEVICE parameter "notworking[decompressed].pdf" fails while simply changing the page size to A4 seems to fix the problem. (it is kind of embarassing now that I notice, but this was the difference between the two systems: I was using a different command line, on dev I did not include an -sDEVICE option, thought that the output method was irrelevant) Hope you have time to give to these issues ... It is not a blocker for us any more so I lowered Severity/Priority. thank you again
Created attachment 4820 [details] patch When /JBIG2Decode filter takes /.jbig2globalctx parameter and retains a pointer to it, the filter must not be allocated in global memory if the parameter is local.
The patch is committed as a rev. 9514. Regression testing shows no differences.