Bug 691894

Summary: Error reading PDF file: /stackunderflow in --run--
Product: Ghostscript Reporter: Marcos H. Woehrmann <marcos.woehrmann>
Component: PDF InterpreterAssignee: Alex Cherepanov <alex>
Status: NOTIFIED FIXED    
Severity: normal    
Priority: P2    
Version: master   
Hardware: PC   
OS: All   
Customer: 580 Word Size: ---
Attachments: patch

Description Marcos H. Woehrmann 2011-01-18 04:09:15 UTC
The customer reports and I've verified that the attached PDF file generates an "Error: /stackunderflow in --run--" error when opened with Ghostscript head (r12034), 9.00, and earlier versions.  Acrobat 10.0.0 and Apple Preview 5.0.3 open the file without complaint.

muPDF opens the file, but produces a warning:

+ mupdf/pdf_xref.c:63: pdf_readstartxref(): cannot find startxref
| mupdf/pdf_xref.c:493: pdf_loadxref(): cannot read startxref
\ mupdf/pdf_xref.c:549: pdf_openxrefwithstream(): trying to repair


The command line I'm using for testing:

  bin/gs -sDEVICE=ppmraw -o test.ppm ./Jalousie.pdf
Comment 2 Marcos H. Woehrmann 2011-01-18 04:12:37 UTC
Not that it's particularly informative, but here is the -dPDFDEBUG output:

GPL Ghostscript SVN PRE-RELEASE 9.01 (2010-09-14)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
   **** Warning: File has a corrupted %%EOF marker, or garbage after %%EOF.
<<
/Linearized 1 /L 529248 /O 122 /E 30130 /N 16 /T 526860 /H [
1576 710 ]
>>
   **** Warning:  An error occurred while reading an XREF table.
   **** The file has been damaged.  This may have been caused
   **** by a problem while converting or transfering the file.
   **** Ghostscript will attempt to recover the data.
Error: /stackunderflow in --run--
Operand stack:
   14
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1894   1   3   %oparray_pop   1893   1   3   %oparray_pop   1877   1   3   %oparray_pop   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--
Dictionary stack:
   --dict:1152/1684(ro)(G)--   --dict:1/20(G)--   --dict:82/200(L)--   --dict:82/200(L)--   --dict:108/127(ro)(G)--   --dict:296/300(ro)(G)--   --dict:20/30(L)--
Current allocation mode is local
GPL Ghostscript SVN PRE-RELEASE 9.01: Unrecoverable error, exit code 1
Exit 1
Comment 3 Alex Cherepanov 2011-01-20 04:20:48 UTC
Created attachment 7143 [details]
patch

Search for 'trailer' harder: at the end and at the beginning of the file.
This helps to recover some more of broken linearized files.
Comment 4 Alex Cherepanov 2011-01-20 04:24:06 UTC
The patch has been committed as a rev. 12040.