Bug 705014 - "pclm" output device crashes on PDF from pdftopdf filter
Summary: "pclm" output device crashes on PDF from pdftopdf filter
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Writer (show other bugs)
Version: 9.55.0
Hardware: PC Linux
: P2 normal
Assignee: Michael Vrhel
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-25 22:16 UTC by Till Kamppeter
Modified: 2022-03-07 22:22 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
test-gs-pclm.pdf (315.13 KB, application/pdf)
2022-02-25 22:16 UTC, Till Kamppeter
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Till Kamppeter 2022-02-25 22:16:16 UTC
Created attachment 22194 [details]
test-gs-pclm.pdf

Running the following command line with the attached PDF input file (from pdftopdf filter of cups-filters) causes a crash:

cat test-gs-pclm.pdf | gs -dQUIET -dSAFER -dNOPAUSE -dBATCH -dNOINTERPOLATE -dNOMEDIAATTRS -dUsePDFX3Profile -sstdout=%stderr -sOutputFile=%stdout -r600x600 -sDEVICE=pclm -dStripHeight=64 -sCompression=Flate -dDownScaleFactor=1 -dDEVICEWIDTHPOINTS=612 -dDEVICEHEIGHTPOINTS=792 -I/usr/share/cups/fonts -sOutputICCProfile=sgray.icc -c '<</.HWMargins[11.990551 11.990551 11.990540 11.990540] /Margins[0 0]>>setpagedevice' -f -_ > out

As output I get

   **** File has no /OutputIntents attribute
malloc(): invalid size (unsorted)
Aborted (core dumped)

The file "out" should get a PCLm file when Ghostscript had completed. In my case it only contains the first 8192 bytes of the expected PCLm file. A complete PCLm file can be displayed with a PDF viewer. My "out" file does not even show a part of the content. The "file" command identifies the file as PDF (as it usually dos with PCLm files), even not being complete.
Comment 1 Till Kamppeter 2022-02-25 22:19:10 UTC
System is Ubuntu Jammy (22.04 LTS), amd64.
Comment 2 Ken Sharp 2022-02-26 10:28:08 UTC
This considerably simpler command line :

-sDEVICE=pclm -sOutputICCProfile=sgray.icc  -o out.pclm test-gs-pclm.pdf

exhibits what I believe to be the same problem. Remove the -sOutputICCProfile= and the command runs to completion. Using ppmraw instead of pclm still crashes.

On Windows, running under a debugger I'm seeing a seg fault in (essentially) malloc() from gx_path_new_subpath(), from pdf14_stroke_path().

However I suspect (given the necessity of including -sOutputICCProfile) that this is probably not where the actual problem occurs. Also using ppmraw give me a heap corruption error (in malloc) from make_table_template() from gx_scan_convert_tr_app().

Given that it 'appears' to be related to ICC profiles, and possibly transparency, I'm assigning it to Michael, though that may need to change, it could be scan conversion, memory management or clist at fault.
Comment 3 Michael Vrhel 2022-03-07 22:22:26 UTC
Fixed with http://git.ghostscript.com/?p=ghostpdl.git;a=commit;h=648937e3ee1a05a475be57ed590b4913e4eedce9

Note that the command line you give will now throw an error
as you are specifying a gray color space ICC profile for
a pclm device which requires an RGB color space profile.