Bug 695418

Summary: Testing GhostScript 9.14 - page 130 throws an error
Product: Ghostscript Reporter: DKM <Dennis.Miller>
Component: PS InterpreterAssignee: Ken Sharp <ken.sharp>
Status: RESOLVED WONTFIX    
Severity: normal CC: Dennis.Miller
Priority: P4    
Version: 9.14   
Hardware: PC   
OS: Windows 7   
Customer: Word Size: ---
Attachments: Postscript file

Description DKM 2014-08-08 14:45:18 UTC
I have a process that create a PDF form a number of postscript files.  I have testeed with multiple processes that generate different PS files.  Ghostscript is throwing this error on Page 130 for all tests.

ERROR: limitcheck
OFFENDING COMMAND: .makeoperator
STACK:
{--dup-- /FontType --eq-- 2 --index-- 32 --eq-- --and-- {--pop-- --pop
-- false }{--resourcestatus-- }--ifelse-- }
/resourcestatus
/resourcestatus
-dictionary-
( Version 5.2.2)
/Creator
-dictionary-
-dictionary

If I test with a differetn Ghostscript 7.06 it works fine.  Any number of pages less then 130 builds OK.  This is the command line
  -q -dSAFER -dNOPAUSE -dBATCH -sDEVICE#pdfwrite -dCompatibilityLevel#1.3 sOutputFile#"pdfFileName" -c .setpdfwrite -f "psFileName"

The PSFile is a concatenated set of postscript files.
Comment 1 DKM 2014-08-08 14:48:14 UTC
Created attachment 11105 [details]
Postscript file

postscript file that is failing.
Comment 2 Ken Sharp 2014-08-09 06:55:08 UTC
This is nothing to do with ps2write (the 'PS writer') since the error occurs even with the display device (and in any event pdfwrite is the PDF writer....)

Concatenating PostScript files is a good way to come up with files that don't work, its highly not recommended. This is because PostScript is a programming language, so in effect you are concatenating multiple programs, and expecting them to work. You might be lucky (people often are) but its a bad way to proceed.

In this case the concatenated files are not simply PostScript, they have been printed to a HP printer driver, so each file includes PJL and, critically, a control-D, end of job marker.

That causes the DSC parser to reset, which causes it to reinitialise on the next job, which picks up the 'Creator' comment (all the files having been produced from the Windows Pscript5.dll driver) and creates a new operator. When the number of operators defined exceeds the size of the operator table, a limitcheck occurs.

Removing the control-D bytes causes the file to run to completion.

The simplest solution seems to me to be not to concatenate files. As an alternative, prepending this:

<004> cvn {} bind def

redefines the Control-D eoj marker as a no-op and the file runs to completion.
Comment 3 DKM 2014-08-11 09:02:36 UTC
I did some regressing testing and 9.10 works fine.  Does 9.14 have a different DSC parser? Also the <004> cvn {} bind def – would I inject that into the Postscript on the first file or every file.

thanks
Comment 4 Ken Sharp 2014-08-11 12:39:36 UTC
(In reply to DKM from comment #3)
> I did some regressing testing and 9.10 works fine.  Does 9.14 have a
> different DSC parser?

No, but its not the DSC parser as such but the fact that the DSC parser gets re-initialised on every 0x004 character in the data stream (outside of binary objects such as images and fonts obviously)


> Also the <004> cvn {} bind def – would I inject that
> into the Postscript on the first file or every file.

It redefines the routine to do nothing, you only need to do it once. You don;t even need to put it on any file, you can supply it on the command line.

Please don't change the status of the bug.
Comment 5 DKM 2014-08-11 14:19:42 UTC
Thanks for the response, I’m not familiar with using that command on the command line.  Do you have a sample?  Also is it a defect in 9.14 because 9/10 and 9.09 both work without it.
Comment 6 Ken Sharp 2014-08-12 00:03:52 UTC
(In reply to DKM from comment #5)
> Thanks for the response, I’m not familiar with using that command on the
> command line.  Do you have a sample?

See the documentation on -c and -f

>  Also is it a defect in 9.14 because
> 9/10 and 9.09 both work without it.

Not in my opinion. Concatenating PostScript files is a Bad Idea, and liable to fail for any number of reasons.
Comment 7 DKM 2014-08-12 09:36:11 UTC
trying to implement your suggestion to use <004> cvn {} bind def. I'm getting an error trying to use the command line
gswin32c -q -dSAFER -dNOPAUSE -dBATCH -sDEVICE#pdfwrite -dCompatibilityLevel#1.4 -sOutputFile#"%2" -f"%1" -c .setpdfwrite cvn {} bind def setdistillerparams

Getting unrecoverable error, exit code 1
ERROR: stackunderflow
OFFENDING COMMAND: cvn
OPERAND STACK:
Comment 8 Ken Sharp 2014-08-12 13:22:52 UTC
(In reply to DKM from comment #7)
> trying to implement your suggestion to use <004> cvn {} bind def. I'm
> getting an error trying to use the command line
> gswin32c -q -dSAFER -dNOPAUSE -dBATCH -sDEVICE#pdfwrite
> -dCompatibilityLevel#1.4 -sOutputFile#"%2" -f"%1" -c .setpdfwrite cvn {}
> bind def setdistillerparams

Frankly this is nonsense. It isn't a command line, its part of a batch file, you should start with the commend line (command shell if you like) and only try and turn it into a batch file after you have it working.

I have no idea what the %2 and %1 batch parameters are supposed to be, but you haven't added what I suggested, the <004> is missing, the proposed change "<004> cvn {} bind def" follows the -c, but I see that before that you have a "-f %1" which I take to be the filename, so it'll run the file before it gets to the -c etc.

If you want it to have any effect, it must precede the input file.