Bug 693033

Summary: Ghostscript goes into an infinite loop (failing pdf input attached)
Product: Ghostscript Reporter: Juliusz Gonera <juliusz.gonera>
Component: PDF InterpreterAssignee: Alex Cherepanov <alex>
Status: RESOLVED FIXED    
Severity: major CC: pablo
Priority: P4    
Version: master   
Hardware: PC   
OS: Linux   
Customer: Word Size: ---
Attachments: failing pdf input
File that causes infinite loop while trying to render the first page into jpg
Simplified sample file

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