Bug 695645 - PDFWrite fails on file with Error: /typecheck in --run--
Summary: PDFWrite fails on file with Error: /typecheck in --run--
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Interpreter (show other bugs)
Version: 9.15
Hardware: PC Linux
: P4 normal
Assignee: Ken Sharp
QA Contact: Bug traffic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-27 11:32 UTC by Josh
Modified: 2014-10-28 10:11 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
file causing the bug (502.38 KB, application/pdf)
2014-10-27 11:32 UTC, Josh
Details
Fixed specimen file (521.95 KB, application/pdf)
2014-10-28 09:38 UTC, Ken Sharp
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Josh 2014-10-27 11:32:35 UTC
Created attachment 11275 [details]
file causing the bug

I've attached the file.  The file is 4 pages, but the output is only 2 pages.  Command I'm running:

gs -o out.pdf -sDEVICE=pdfwrite 200365584.pdf 

What I'm seeing in my terminal:

GPL Ghostscript 9.14 (2014-03-26)
Copyright (C) 2014 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 4.
Page 1
Loading NimbusSanL-Regu font from %rom%Resource/Font/NimbusSanL-Regu... 4011732 2491012 2176520 754081 3 done.
Loading NimbusSanL-Bold font from %rom%Resource/Font/NimbusSanL-Bold... 4028660 2526529 2176520 747321 3 done.
Page 2
Page 3
Error: /typecheck in --run--
Operand stack:
   --dict:11/20(L)--   --nostringval--   false   --nostringval--   F
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1918   1   3   %oparray_pop   1917   1   3   %oparray_pop   1901   1   3   %oparray_pop   --nostringval--   --nostringval--   4   1   4   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %array_continue   --nostringval--   --nostringval--   --nostringval--
Dictionary stack:
   --dict:1171/1684(ro)(G)--   --dict:1/20(G)--   --dict:82/200(L)--   --dict:82/200(L)--   --dict:114/127(ro)(G)--   --dict:281/300(ro)(G)--   --dict:28/32(L)--   --dict:6/8(L)--   --dict:22/40(L)--
Current allocation mode is local
Last OS error: No such file or directory
GPL Ghostscript 9.14: Unrecoverable error, exit code 1


Thanks ahead of time!
Comment 1 Josh 2014-10-27 11:33:06 UTC
I've tried this on 9.14 and 9.15.  Terminal output is from 9.14
Comment 2 Ken Sharp 2014-10-27 12:41:03 UTC
The file fails on Ghostscript with any device, not merely pdfwrite, which would tend to indicate a problem with the PDF file itself.
Comment 3 Ken Sharp 2014-10-27 12:50:10 UTC
The PDF file is definitely broken, Acrobat displays page 3 as blank when it clearly shouldn't be.
Comment 4 Josh 2014-10-27 12:58:47 UTC
Understood.  Shouldn't Ghostscript also skip the page then and finish the processing of the document?
Comment 5 Ken Sharp 2014-10-27 14:57:24 UTC
(In reply to Josh from comment #4)
> Understood.  Shouldn't Ghostscript also skip the page then and finish the
> processing of the document?

Depending on the nature of the error that may or may not be possible. Fundamentally when a PDF file doesn't conform to the specification, its wrong, and there is no defined behaviour. In general we try to do 'what Acrobat does' when we can.
Comment 6 Ken Sharp 2014-10-28 09:38:39 UTC
Created attachment 11283 [details]
Fixed specimen file

The PDF file is invalid, it contains this:

  /Contents [ 46 0 R 71 0 R ]

Each entry in the Contents array must be a stream objcet, but object 46 is defined as :

46 0 obj
[ 47 0 R 48 0 R 49 0 R 50 0 R 51 0 R 52 0 R 53 0 R 54 0 R ]
endobj

Which is an array, not a stream. Since it has the wrong type, you get a typecheck error.

When I correct this, Acrobat shows page 3 with content, I mention this just to prove that the file *is* invalid.
Comment 7 Ken Sharp 2014-10-28 10:11:40 UTC
commit cd2c4af1dd92bc4cc32170254c84498792913c0e checks the entries in the Contents array and if they aren't valid emits a warning, drops the current object and terminates the loop processing the Contents array entry (as Acrobat apparently does).

You should probably tell whoever produced this file that its broken and get the authoring software (Prawn apparently) fixed.