Bug 692532 - Ghostscript crashes in color code on PDF input file
Summary: Ghostscript crashes in color code on PDF input file
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Interpreter (show other bugs)
Version: 9.04
Hardware: PC Linux
: P4 normal
Assignee: Chris Liddell (chrisl)
URL:
Keywords:
: 692754 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-09-22 20:32 UTC by Till Kamppeter
Modified: 2011-12-22 08:36 UTC (History)
2 users (show)

See Also:
Customer:
Word Size: ---


Attachments
/home/till/CityMap-evince-pdftopdf.pdf (503.20 KB, application/pdf)
2011-09-22 20:32 UTC, Till Kamppeter
Details
patch for gs_lev2.ps (954 bytes, patch)
2011-09-23 14:55 UTC, Chris Liddell (chrisl)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Till Kamppeter 2011-09-22 20:32:36 UTC
Created attachment 7910 [details]
/home/till/CityMap-evince-pdftopdf.pdf

Original Ubuntu bug reports:

https://bugs.launchpad.net/ubuntu/+source/ghostscript/+bug/842411
https://bugs.launchpad.net/ubuntu/+source/ghostscript/+bug/842435
https://bugs.launchpad.net/ubuntu/+source/ghostscript/+bug/853918

The bugs contain all symbolic stack traces, but the users did not attach their input files. So I tried to reproduce it by myself and got

https://bugs.launchpad.net/ubuntu/+source/ghostscript/+bug/856766

The Ubuntu bug tracking system will add a stack trace here, too.

The command line to reproduce it is

cat ~/ghostscript/testfiles/CityMap-evince-pdftopdf.pdf | /usr/bin/gs -dQUIET -dPARANOIDSAFER -dNOPAUSE -dBATCH -dNOINTERPOLATE -sDEVICE=cups -sstdout=%stderr -sOutputFile=%stdout -sMediaType=Plain -sOutputType=0 -r300x600 -dMediaPosition=7 -dDEVICEWIDTHPOINTS=612 -dDEVICEHEIGHTPOINTS=792 -dcupsBitsPerColor=8 -dcupsColorOrder=0 -dcupsColorSpace=17 -dcupsInteger0=2 -scupsPageSizeName=Letter -I/usr/share/cups/fonts -c -f -_ > out.raster

The output is

INFO: Start rendering...
INFO: Processing page 1...
sfopen: gs_parse_file_name failed.
sfopen: gs_parse_file_name failed.
  ./base/gsicc_manage.c:866: gsicc_open_search(): Could not find ps_gray.icc 
| ./base/gsicc_manage.c:198: gsicc_initialize_iccsmask(): failed to load gray smask profile
Segmentation fault (core dumped)

The input file is also attached here.
Comment 1 Till Kamppeter 2011-09-22 20:38:17 UTC
The retracer of Launchpad considered my bug report

https://bugs.launchpad.net/ubuntu/+source/ghostscript/+bug/856766

as the same as

https://bugs.launchpad.net/ubuntu/+source/ghostscript/+bug/842435

so have especially a look into the stack trace there.
Comment 2 Alex Cherepanov 2011-09-23 04:46:16 UTC
This works for me for v. 9.04 and current development version
with the default build.
Comment 3 Till Kamppeter 2011-09-23 07:47:20 UTC
Ales, can you boot a live CD of Ubuntu Oneiric beta2 and check there? The patches we are using are all backports from the Ghostscript repo, but perhaps some of them need additional backports.
Comment 4 Chris Liddell (chrisl) 2011-09-23 08:44:53 UTC
The crash is because we are ignoring the error return value from gsicc_initialize_iccsmask() at line 587 in base/gstrans.c having failed to load the required ICC profile.

As for why we're failing to find ps_gray, I don't know. It *seems* to be finding the default_*.icc files, which are in the same directory. Using -sICCProfilesDir=... doesn't seem to work, either, don't know why.


So, fixing the crash is easy enough, line 587 in base/trans.c, change:

        code = gsicc_initialize_iccsmask(icc_manager);

to:
        code = gsicc_initialize_iccsmask(icc_manager);
        if (code < 0)
            return(code);
Comment 5 Chris Liddell (chrisl) 2011-09-23 09:07:57 UTC
So, it looks like the reason -sICCProfilesDir doesn't have the desired effect here is that gs_vmreclaim() is being called during the job, and is having the effect of returning the ICC profile path in the current context to the default value (which is the empty "%rom%iccprofiles0" in this case).

I am still unclear how the installed version on Oneiric finds the "default_*.icc" profiles, then fails to find the ps_gray.icc, *but* I suspect it is related to the above issue with the command line parameter.


That's about as far as I can take this..........
Comment 6 Till Kamppeter 2011-09-23 10:19:22 UTC
The crash went away actually with the fix from comment #4. I have applied the fix to the Ubuntu Oneiric package (9.04~dfsg-0ubuntu9) now.

Thank you very much.

I leave the bug open, as the more important part of the fix, finding the profiles at all, is still missing.
Comment 7 Chris Liddell (chrisl) 2011-09-23 14:55:11 UTC
Created attachment 7911 [details]
patch for gs_lev2.ps

This fairly simple patch resolves the problem of failing to find the ICC profiles directory (and of -sICCProfilesDir= not working correctly) for me.
Comment 8 Till Kamppeter 2011-09-23 15:05:34 UTC
That's it. I have tested my case and now it works perfectly! Thanks.
Comment 9 Chris Liddell (chrisl) 2011-09-23 16:04:03 UTC
I've committed the change in the patch:

http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=568854
Comment 10 Chris Liddell (chrisl) 2011-12-22 08:36:10 UTC
*** Bug 692754 has been marked as a duplicate of this bug. ***