Starting with tr11595 Ghostscript generates an "Error: /rangecheck in 3" with the following command line: ./bin/gs -sDEVICE=pdfwrite -o test.pdf -dLastPage=1 ./RodinCIDEmbed.pdf
Rev. 11595 has a few problems, which I missed during the review. 1. signalerror takes 2 operands. 2. not all calls to linkdest were in the stopped context. My patch is incomplete because the error message it prints is false. The user doesn't need to "notify the author of the software" because the PDF is fine. We just view it in an unusual way. I didn't yet figure out how to fix this. It is possible to check whether the page is within a valid range (1..PageCount) and throw a different error. Later one can print different messages depending on the operator name that throws the error. I hope there are better ways to do this.
Created attachment 6633 [details] partial patch
Alex, are you still looking at this, or want me to take it back ?
*** Bug 691722 has been marked as a duplicate of this bug. ***
I'm not sure if it will help, but Ghostscript 8.71 is able to extract page 2 of the document I uploaded with Bug 691722, when Ghostscript 9.0 fails. Ghostscript 8.71 mentions an error, though: GPL Ghostscript 8.71: ERROR: A pdfmark destination page 13 points beyond the last page 1. The gs output is fine, even with this error.
The fix in revision 11595 was intended to remove pdfmarks which point to pages which are outside the FirstPage/LastPage range, so that we don't produce PDF files with incorrect destinations. Prior to this (eg GS 8.71) the destination could be written to the output file, but since this revision is the one introducing the problem, the file would otherwise work.
The problem seems to have been resolved, probably by Alex's fix to run streams in a stopped context: http://ghostscript.com/pipermail/gs-cvs/2011-June/012998.html I'm not certain if Alex's patch in comment #3 still needs to be committed, so I'm assigning to Alex to review this. Please just close the bug if its not required.
The oath #3 has been committed as a rev. 0f592834 on 2011-05-10 00:21:21.