Bug 688433

Summary: Error: /rangecheck in --.buildshading2--
Product: Ghostscript Reporter: Matt Kynx <matt>
Component: PDF InterpreterAssignee: Alex Cherepanov <alex>
Status: NOTIFIED FIXED    
Severity: normal    
Priority: P3    
Version: 8.53   
Hardware: PC   
OS: Linux   
Customer: Word Size: ---
Attachments: patch
improved patch

Description Matt Kynx 2005-12-09 08:41:11 UTC
I'm having problems turning a PDF into a TIFF (-sDEVICE#tiff24nc). The error I
get is:

AFPL Ghostscript 8.53 (2005-10-20)
Copyright (C) 2005 artofcode LLC, Benicia, CA.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1
Error: /rangecheck in --.buildshading2--
Operand stack:
   --dict:10/10(L)--   1   --dict:8/8(L)--   --dict:8/8(L)--
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--  
--nostringval--   2   %stopped_push   --nostringval--   --nostringval--  
--nostringval--  false   1   %stopped_push   1   3   %oparray_pop   1   3  
%oparray_pop   1   3   %oparray_pop   --nostringval--   --nostringval--   2   1
  1   --nostringval--   %for_pos_int_continue   --nostringval--  
--nostringval--   --nostringval--   --nostringval--   %array_continue  
--nostringval--   false   1   %stopped_push   --nostringval--   %loop_continue 
 --nostringval--   38606   --nostringval--   3   15   %oparray_pop  
--nostringval--   false   1   %stopped_push   3   15   %oparray_pop  
--nostringval--   (gstatetype)   --dict:0/0(L)--   --nostringval--   false   1 
 %stopped_push   --nostringval--   %loop_continue  3   18   %oparray_pop  
--nostringval--   false   1   %stopped_push   --nostringval--
Dictionary stack:
   --dict:1127/1686(ro)(G)--   --dict:2/20(G)--   --dict:75/200(L)--  
--dict:75/200(L)--   --dict:105/127(ro)(G)--   --dict:258/347(ro)(G)--  
--dict:21/24(L)--   --dict:4/6(L)--   --dict:21/32(L)--   --dict:1/1(ro)(G)--  
--dict:16/20(L)--   --dict:1/1(ro)(G)--   --dict:1/1(ro)(G)--   --dict:3/5(L)--
  --dict:1/1(ro)(G)--   --dict:1/1(ro)(G)--   --dict:1/1(ro)(G)--   --dict:5/5(L)--
Current allocation mode is local
AFPL Ghostscript 8.53: Unrecoverable error, exit code 1

I've seen mention of this error to do with Quark-generated PDFs before, but I
don't think this is the case here.

Acrobat Reader's Document Properties reports:
Application: Adobe InDesign CS (3.0.1)
PDF Producer: Adobe PDF Library 6.0
PDF Version: 1.3 (Acrobat 4.x)

The document in question is around 600K and consists of a customer's artwork, so
I'd rather not attach it to this report. Please contact me directly if it would
help get to the cause of this problem.
Comment 1 Alex Cherepanov 2005-12-09 09:05:29 UTC
Little can be done without the sample file. You can try to remove the sensitive
parts of the document usung Adobe Acrobat.

File attachments can be marked private. Private attachments can be accessed by a
small number of Ghostscript developers who have a NDA with Artifex Software.
Comment 2 Matt Kynx 2005-12-09 09:51:50 UTC
Created attachment 1850 [details]
PDF causing the error
Comment 3 Alex Cherepanov 2005-12-09 15:30:11 UTC
Created attachment 1851 [details]
patch

Some bounding boxes in the sample file have y0 > y1 .
Normalize the BBox in the shading dictionary when needed.
Comment 4 Dan Coby 2005-12-09 20:49:38 UTC
Note:  There are procedures called normrect and normrect_elems in 
lib/pdf_main.ps which will 'normalize' a rectangle.
Comment 5 Alex Cherepanov 2005-12-10 06:10:49 UTC
Created attachment 1852 [details]
improved patch

A shorter patch that uses an existing function.
Comment 6 Matt Kynx 2005-12-12 04:09:49 UTC
Ghostscript 8.53 with the improved patch works a charm! Many thanks for looking
into this.

Matt
Comment 7 Stefan Kemper 2005-12-14 10:21:39 UTC
Alex please commit the patch and close the bug.  
Comment 8 Alex Cherepanov 2005-12-14 13:35:20 UTC
The fix is committed to the HEAD branch.