Bug 690427 - limitcheck in pdfmark during generation of postscript
Summary: limitcheck in pdfmark during generation of postscript
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Writer (show other bugs)
Version: 8.64
Hardware: PC Linux
: P4 normal
Assignee: Ken Sharp
QA Contact: Bug traffic
Depends on:
Reported: 2009-04-18 03:23 UTC by andrew collier
Modified: 2009-04-19 02:24 UTC (History)
1 user (show)

See Also:
Word Size: ---

ps file that breaks (683.88 KB, application/postscript)
2009-04-18 03:24 UTC, andrew collier
outline.png (129.07 KB, image/png)
2009-04-18 08:48 UTC, Ken Sharp
the full table of contents (736.75 KB, application/postscript)
2009-04-18 09:04 UTC, andrew collier
broken document structure (36.99 KB, image/jpeg)
2009-04-18 11:25 UTC, andrew collier

Note You need to log in before you can comment on or make changes to this bug.
Description andrew collier 2009-04-18 03:23:30 UTC

i am having trouble generating a pdf file from a ps file. the ps is from latex
and it is a relatively large (154 page) document. when i try to process the
whole file  i get:

$ ps2pdf electrodynamics.ps 
Error: /limitcheck in --pdfmark--
Operand stack:
   --nostringval--   Count   -3   Dest   figure.7.2   Title   (General
Description)   OUT
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--  
--nostringval--   2   %stopped_push   --nostringval--   --nostringval--  
--nostringval--   false   1   %stopped_push   1862   1   3   %oparray_pop   1861
  1   3   %oparray_pop   1845   1   3   %oparray_pop   1739   1   3  
%oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--  
--nostringval--   --nostringval--   2   %stopped_push   --nostringval--   1863 
 8   5   %oparray_pop   --nostringval--
Dictionary stack:
   --dict:1152/1684(ro)(G)--   --dict:0/20(G)--   --dict:75/200(L)--  
--dict:210/300(L)--   --dict:32/200(L)--
Current allocation mode is local
Last OS error: 2
Current file position is 696147
GPL Ghostscript 8.64: Unrecoverable error, exit code 1

i thought that perhaps the big file was breaking ghostscript, so i selected only
the first page, saved that, giving:

$ ls -l electrodynamics.ps_pages
-rw-r--r-- 1 colliera users 700296 2009-04-18 12:03 electrodynamics.ps_pages

i then ran ps2pdf again and got the same result. i dug into the ps file and find
that the place where it breaks is in the formatting of the document index. here
is an extract:

SDict begin [ /Count -5 /Dest (table.6.1) cvn /Title (Waveguides) /OUT
pdfmark end
 -104 -39 a -104 -39
SDict begin [ /Count -0 /Dest (section*.76) cvn /Title (Introduction)
/OUT pdfmark end
 -104 -39 a -104 -39 a
SDict begin [ /Count -3 /Dest (figure.7.2) cvn /Title (General Description)
/OUT pdfmark end
 -104 -39 a -104 -39 a
SDict begin [ /Count -0 /Dest (figure.7.3) cvn /Title (TE Mode) /OUT
pdfmark end
 -104 -39
a -104 -39 a

you can see the line mentioned in the error dump somewhere around the middle of
that. i am rather perplexed as to why this is happening. if i trim down the tex
file to include only a few chapters then sometimes i can get a pdf. if i choose
different chapters then i run into the same problem.

i have made the offending ps file available at

please help!

best regards,
Comment 1 andrew collier 2009-04-18 03:24:37 UTC
Created attachment 4941 [details]
ps file that breaks
Comment 2 Ken Sharp 2009-04-18 08:48:41 UTC
Created attachment 4942 [details]

Your Outline tree is enormously complicated and branches to a significant
depth. pdfwrite has a maximum depth for the outline tree of 31, your tree
exceeds 40.

This is a compile-time setting, you can rebuild Ghostscript and modify the
definition of MAX_OUTLINE_DEPTH in /gs/base/gdevpdfx.h where it is currently
defined as 32 (maximum is definition -1).

I don't wish to seem critical, but is it possible that the outline here is
incorrectly constructed ? 

I notice that 'Time-Independent Maxwell's Equations' is a node under
'Problems', which is a node under 'Vectors and Tensors'. Should Maxwell's
equations not be a node at the same level as Vectors and Tensors ?

I see this happen repeatedly in the course of the outline tree, for example see
also 'The Wien Law'->Temperature->Waveguides->->Problems->'Special Relativity'.

Perhaps this is intentional, its hard to tell with only the first page to look
at :-) I've attached a PNG of my Acrobat display of this outline to help you
determine whether this is correct.

If you really do want an outline tree of this depth please let me know and I
will increase the maximum in future versions.
Comment 3 andrew collier 2009-04-18 09:02:51 UTC
hi ken,

thanks for your response. i see what you mean with the nesting of those
sections. but my table of contents looks fine... please see the attachment. so,
although in your viewer it appears that special relativity is nested under
problems, in the ps file it is in a separate chapter. this is VERY weird and i
am not sure whether the problem is with gs or latex.

any further ideas?

Comment 4 andrew collier 2009-04-18 09:04:30 UTC
Created attachment 4943 [details]
the full table of contents
Comment 5 Alex Cherepanov 2009-04-18 09:50:39 UTC
The PS file may have unintended outline structure but Distiller 5
can process the file just fine. Probably, the compile time limit should be
increased or removed completely.
Comment 6 andrew collier 2009-04-18 11:23:49 UTC
okay, i increased the compile time limit, rebuilt the code... and now the pdf is
generated without any errors. however there is still a problem with the document
structure. have a look at the screendump from xpdf: later chapters all get
grouped in under the last section of the first chapter. since it looks like
there is something fishy in the postscript, i guess that the problem here is
maybe not with ps2pdf but with dvips?
Comment 7 andrew collier 2009-04-18 11:25:31 UTC
Created attachment 4944 [details]
broken document structure
Comment 8 Ken Sharp 2009-04-19 02:24:02 UTC
Hi Andrew,

The printed table of contents is not the same as the outline tree displayed in a
PDF. The outline tree is built using PDF-specific 'pdfmark' operators which have
no effect on printed output, they only affect the production of PDF files.

The outline tree in my attachment was actually produced with Acrobat Distiller
9, though the GS output is the same (as per your later attachment). I think the
mismatch between what you want and what you get is a LaTex problem, it needs to
generate the pdfmarks commands specially, and I guess its doing it wrong.
Possibly its something to do with dvips as you say, I'm not very familiar with
either. You would have to take this up with the TeX/LaTeX developers I can't
help on that one.

Alex, although Acrobat can create an outline of this depth, its not what's
wanted, and to be honest is less than useful. Of course it would be nice to
remove the limitation, but that'll involve quite a bit of coding. At the moment,
the outline tree is built in a static array. I'll add an enhancement request to
convert it to a dynamic list instead, but with a low priority. For now I'm
marking this as INVALID.

Andrew, I'm sorry I can't help you with the generation of the PostScript, all I
can say is that Ghostscript is doing what's expected of it, the structure
generated by the pdfmark operators is incorrect I'm afraid, which comes form the
generating application.