Bug 693033 - Ghostscript goes into an infinite loop (failing pdf input attached)
Summary: Ghostscript goes into an infinite loop (failing pdf input attached)
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Interpreter (show other bugs)
Version: master
Hardware: PC Linux
: P4 major
Assignee: Alex Cherepanov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-09 11:24 UTC by Juliusz Gonera
Modified: 2013-01-09 07:42 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments
failing pdf input (3.37 MB, application/pdf)
2012-05-09 11:24 UTC, Juliusz Gonera
Details
File that causes infinite loop while trying to render the first page into jpg (1012.50 KB, application/pdf)
2012-06-15 17:07 UTC, Pablo Castellano
Details
Simplified sample file (1.91 KB, application/pdf)
2012-06-19 20:01 UTC, Alex Cherepanov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Juliusz Gonera 2012-05-09 11:24:23 UTC
Created attachment 8579 [details]
failing pdf input

Environment
------------

Tested against ghostscript 9-04, 9-05, latest version from master branch (git repo)


Invocation
----------

ghostscript -q -dBATCH -dNOPAUSE -sDEVICE=jpeg -r200x200 -sOutputFile=page_%02d.jpg pg_0002.pdf


Output (looping message)
------------------------

**** File has unbalanced q/Q operators (too many Q's) ****


Expected output
---------------

Jpeg file is not created as it should be, program does not halt.
Comment 1 Alex Cherepanov 2012-05-21 05:47:38 UTC
The problem is caused by an incorrect stitching function in the PDF file
and a problem in the error handler.

Verifying the arguments of the stitching function should be not particularly
difficult.
Comment 2 Pablo Castellano 2012-06-15 17:07:24 UTC
Created attachment 8692 [details]
File that causes infinite loop while trying to render the first page into jpg

Today I have had the same problem. I'm attaching here the PDF that made gs enter into an infinite loop.

I was running:
gs -sDEVICE=jpeg -sOutputFile=- -dFirstPage=1 -dLastPage=1 -r150 -dBATCH -dNOPAUSE -q Triptico-guifi1A.pdf

Thanks for your work!
Comment 3 Alex Cherepanov 2012-06-16 03:37:19 UTC
The problem reported in the comment 2 is now tracked as a bug 693134.
It is completely unrelated to the PDF front end issues.
BTW, there's no loop, just very slow rendering.
Comment 4 Alex Cherepanov 2012-06-19 20:01:20 UTC
Created attachment 8696 [details]
Simplified sample file
Comment 5 Alex Cherepanov 2013-01-09 07:42:13 UTC
The infinite loop has been fixed earlier.

This fix moves shading dictionary construction into a stopped context.
New code just drops a shading that cannot be constructed or rendered instead
of aborting the whole stream run. It's been committed as a rev.
339fcbd26065c2771a33ea8c805ff70bd097684a