Bug 695082 - ps2write: Some "%%BeginResource" DSC comments have only one "%" character
Summary: ps2write: Some "%%BeginResource" DSC comments have only one "%" character
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PS Writer (show other bugs)
Version: 9.10
Hardware: PC Linux
: P4 normal
Assignee: Ken Sharp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-03 03:28 UTC by Till Kamppeter
Modified: 2014-03-31 07:49 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments
compilers.pdf (858.94 KB, application/pdf)
2014-03-03 03:28 UTC, Till Kamppeter
Details
PS document for Page 70 (generated by ghostscript) (186.75 KB, application/postscript)
2014-03-03 23:23 UTC, Sanjay Kumar
Details
output from modified GS (273.42 KB, application/postscript)
2014-03-04 01:25 UTC, Ken Sharp
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Till Kamppeter 2014-03-03 03:28:02 UTC
Created attachment 10734 [details]
compilers.pdf

Original reports:

https://answers.launchpad.net/hplip/+question/243753
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=740583

Running the Ghostscript command line

gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=ps2write -sOUTPUTFILE=%stdout
-dLanguageLevel=3 -r600 -dCompressFonts=false -dNoT3CCITT
-dNOINTERPOLATE -c 'save pop' -f /tmp/compilers.pdf >
/tmp/printout_gs_9_05.ps

with the attached file compilers.pdf shows "%BeginResource" instead of "%%BeginResource" at some places. This leads to a DSC conformity warning with gsview, and in addition, the HP LaserJet 500 MFP M525 prints an error page telling "ERROR: typecheck OFFENDING COMMAND: known" after the figure on page 70.
Comment 1 Ken Sharp 2014-03-03 06:17:31 UTC
The comment is fixed here 649848310dd4f9400f63c685748e4f76344ba9d7 but this can't be the cause of the problem with the printer.

At first glance it looks like another dodgy PostScript implementation, but the error typecheck on 'known' seems unlikely to be caused by this. I've run the output from ps2write through the 3 different PostScript interpreters I have here, and none exhibit an error.

Can you attach a (compressed) version of the PostScript which causes the problem please (in case my version has somehow been fixed) ? Also can you try printing just page 70 and see if the problem persists ?
Comment 2 Sanjay Kumar 2014-03-03 23:23:04 UTC
Created attachment 10736 [details]
PS document for Page 70 (generated by ghostscript)

Hello Ken,

Thanks a lot for looking into this issue. I printed only page 71 and I could reproduce the issue. Please find the generated file in the attachment. When I open this file in the gsview, I get DSC warning message, however if I select to ignore the warning messages then I can see the page properly. I also see few %%EndResource comments for which there is no corresponding  %%BeginResource comment. I am also working with firmware folks to really get to know what causes firmware to reject the job and print an error message "OFFENDING  command." I will update that info too. But its better to  fix those warning messages in ghostscript. Please let me know if you need any other information.

Thanks,
Sanjay
Comment 3 Ken Sharp 2014-03-04 01:22:53 UTC
(In reply to comment #2)

> Thanks a lot for looking into this issue. I printed only page 71 and I could
> reproduce the issue. Please find the generated file in the attachment.

Can you do it again please, but this time specify -dCompressPages=false on the command line ? It will produce a file which is much easier to deal with.

I think you are using CUPS, and I'm not sure how to specify the additional parameter there, maybe Till can let us both know.


> I open this file in the gsview, I get DSC warning message, however if I
> select to ignore the warning messages then I can see the page properly. I
> also see few %%EndResource comments for which there is no corresponding 
> %%BeginResource comment.

The warnings I see are :

"Unknown in Comments section at line 7:
  %RBINumCopies: 1"

Which is not a comment produced by Ghostscript, this must be added somewhere else (presumably by CUPS).

"DSC Warning
At line 2879:
  %%EndProlog
"

I have no idea what GSView is complaining about here, it is a legal comment which is preceded by a %%BeginProlog.

"%%BeginResource: / %%EndResource
The number of Begin and End comments do not match.
"

This seems to be because a resource has an 'end' but no begin, I'll look at that one. It looks like a FontFile object.

And then a series of

"Unknown in Setup section at line 2922:
  %%"
where the line number differs. In each case these are of the form:

"[{
%%BeginFeature: *HPFTDigit 0
%%
%%EndFeature
} stopped cleartomark
"

Which is not a sequence produced by Ghostscript and since these are all device-specific I presume they have been added by CUPS or some similar processor. It looks like GSView is complaining about the line consisting solely of "%%" and that's plain wrong, that is not any kind of error.

So in summary I've fixed the one which I can fix, the others are not our fault.

I've run the PostScript file you attached to 3 different PostScript interpreters, all of which handled the file correctly, so this does look like yet another broken PostScript printer implementation. We can probably work around this, but will have to spend some time (and quite likely a few dozzen sheets of paper) identifying the problem.

If you are happy to help us out with this then it'll probably be better if we take this to private email, rather than generating a sprawling bug thread.
Comment 4 Ken Sharp 2014-03-04 01:25:13 UTC
Created attachment 10737 [details]
output from modified GS

Here's the output from a locally modified Ghostscript which fixes the missing %%BeginResource. For me this works without warnings under GSview and properly runs through all the local PS interpreters.

Its a decompressed file, so we can use this as the basis to start investigating the error message, assuming this file still exhibits the problem. Please give it a try and let me know the results.
Comment 5 Ken Sharp 2014-03-04 01:49:17 UTC
commit 095ae57e266ee5168f042c26dd2e9d12273efb28 fixes the missing %%BeginResource comments
Comment 6 Sanjay Kumar 2014-03-05 04:03:35 UTC
Thanks a lot Ken. Yes this file also has the same issue. Device prints "OFFENDING COMMAND...". I am working with firmware developers and trying to find out the root cause. I will let you know once I get any update on this. Thanks again.
Comment 7 Ken Sharp 2014-03-31 07:49:44 UTC
This bug report has been idle for nearly 4 weeks now. There is nothign further I can do at this time, as I don't have a printer which exhibits the problem.

I'm prepared to try and work with the reporter to localise the problem (which looks like its specific to a particular printer, or series) and come up with a workaround, but I'll need someone prepared to run test files.

So for now I'm closing this as 'fixed' because the commit fixes the missing comments. If you want to have us try and take this further, and are prepared to work with us running test files, feel free to reopen the report.