Bug 691538 - PDF file generates rangecheck with Ghostscript
Summary: PDF file generates rangecheck with Ghostscript
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Writer (show other bugs)
Version: 8.71
Hardware: PC Linux
: P4 normal
Assignee: Michael Vrhel
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-08 11:05 UTC by Damien Cassou
Modified: 2010-08-09 00:20 UTC (History)
2 users (show)

See Also:
Customer:
Word Size: ---


Attachments
Problematic pdf file (141.38 KB, application/pdf)
2010-08-08 11:05 UTC, Damien Cassou
Details
patch (812 bytes, patch)
2010-08-09 00:18 UTC, Alex Cherepanov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Damien Cassou 2010-08-08 11:05:05 UTC
Created attachment 6631 [details]
Problematic pdf file

I tried to use the following command on my pdf (generated with pdflatex):

gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=test.pdf -c "<< /NeverEmbed [false /Times-Roman /Times-Bold /Courier-Bold] >> setdistillerparams" -f poster-extended-abstract.pdf

with my gs (Ubuntu 10.4), I get:

GPL Ghostscript 8.71 (2010-02-10)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 2.
Page 1
Error: /rangecheck in --run--
Operand stack:
   --dict:7/16(L)--   File
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1878   1   3   %oparray_pop   1877   1   3   %oparray_pop   1861   1   3   %oparray_pop   --nostringval--   --nostringval--   2   1   2   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   false   1   %stopped_push   --nostringval--   --nostringval--
Dictionary stack:
   --dict:1155/1684(ro)(G)--   --dict:1/20(G)--   --dict:75/200(L)--   --dict:75/200(L)--   --dict:108/127(ro)(G)--   --dict:288/300(ro)(G)--   --dict:22/25(L)--   --dict:6/8(L)--   --dict:25/40(L)--   --dict:14/18(ro)(L)--   --dict:2/3(L)--   --dict:3/5(L)--   --dict:1/1(ro)(G)--   --dict:6/12(L)--
Current allocation mode is local
Last OS error: 2
GPL Ghostscript 8.71: Unrecoverable error, exit code 1
Comment 1 Ken Sharp 2010-08-08 11:12:36 UTC
The file generates a /rangecheck error on --.discardtransparencygroup-- for me when using Windows. Both the HEAD and 8.70 revisions. -sDEVICE=ppmraw also gives the same result for me, so its not specific to PDF touput.

Re-assigning to Alex as a PDF interpreter initially, this may need to go to Michael if it turns out to be a transparency problem.
Comment 2 Alex Cherepanov 2010-08-08 22:44:03 UTC
This problem appears first in 
r10200 | mvrhel | 2009-10-20 23:50:46 -0400 (Tue, 20 Oct 2009) | 72 lines
Reintegration of gs_extendgraphic branch into trunk.

If .pushextendedgstate is commented out, the file runs to completion.
/q { ... 
% PDFusingtransparency {.pushextendedgstate cvx} if
... } def

BTW, "PDFusingtransparency {.popextendedgstate cvx} if" should be,
probably, done only for a valid Q, i.e. after the checks.
Comment 3 Alex Cherepanov 2010-08-08 22:52:17 UTC
And why "cvx" ? 
Removing this fixes the bug.
Comment 4 Alex Cherepanov 2010-08-09 00:18:08 UTC
Created attachment 6632 [details]
patch

Remove spurious "cvx" operators after .pushextendedgstate and
.popextendedgstate . Do .popextendedgstate after checking that "Q"
has a correspondingh "q". The latter is not necessary to fix this bug
but may help when PDF file has extra "Q"s .
Comment 5 Alex Cherepanov 2010-08-09 00:20:12 UTC
The patch has been committed as a rev. 11615.
Regression testing shows no differences.