Subject: pkg/24108: ...pkgsrc/print/ghostscript-gnu emits garbage into print output. (workaround)
To: None <gnats-bugs@gnats.netbsd.org>
From: None <rkr@olib.org>
List: netbsd-bugs
Date: 01/15/2004 07:11:20
>Number:         24108
>Category:       pkg
>Synopsis:       ...pkgsrc/print/ghostscript-gnu emits garbage into print output.  (workaround)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 15 13:12:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Richard Rauch
>Release:        NetBSD 1.6ZG
>Organization:
  "I probably don't know what I'm talking about."  http://www.olib.org/~rkr/
>Environment:
System: NetBSD socrates 1.6ZG NetBSD 1.6ZG (socrates) #1: Wed Dec 31 15:24:34 CST 2003 root@socrates:/usr/netbsd/current/src/sys/arch/amd64/compile/obj.amd64/socrates amd64
Architecture: x86_64
Machine: amd64
>Description:
	I set up MS-WINDOWS '98 on another machine and had it talking
	to my NetBSD machines via samba.  I set up my NetBSD printer
	to be visible to MS-WINDOWS and tried to print.

	Printing was fine, but the last page produced a PCL XL error,
	"Subsystem: KERNEL", "Error: IllegalTag", "Operator 0x25".
	(*All* of the real pages printed correctly.  The error page
	was a separate page.)

	What this means is that GhostScript was letting some kind of
	garbage out to the printer, while the printer was expecting
	PCL.  (My printer natively does PCL.  I use GhostScript on
	NetBSD to make the printer look like a PostScript printer.)

	After fiddling around a bit, and peeking at a print-to-file
	copy of the data, I discovered that the problem seems to be
	lines of the form:

	(%%[  Page N  ]%%) =
	(%%[ LastPage ]%%) =

	...these appear to have the intended function of causing a
	physical printer to display a message on its local control
	panel.  However, GhostScript dumps these messages to stdout.

	Regretably, stdout is also where (-sOutputFile=-) the PCL
	graphical output is going.  This appears to be the culprit
	in causing my print jobs to get a trailing error page.

	GhostScript has a feature that is supposed to protect against
	output messages on stdout interfering with using - as the output
	file.  "-q" is supposed to suppress messages, but it does not
	affect *these* messages.  I consider this a bug (or else, it's
	a bug that there's no option---that I know of---for suppressing
	these messages in addition to whatever else "-q" might affect).

	I am frankly a bit surprised that this doesn't cause problems
	in the middle of printing a multiple-page document, but
	perhaps GhostScript saves the errors up to the end?
>How-To-Repeat:
	cd ...pkgsrc/print/ghostscript-gnu && make
	gs -q
	(%%[ foo ]%%) =
			 (note the GhostScript response)
	^D
	make deinstall
>Fix:
	Dunno.  I haven't looked at the code yet.  Probably a
	trivial patch to a bit of code somewhere.  I don't
	know if the authors of GhostScript consider this a bug
	or not.


	One workaround in my case is to rewire my pipeline to use
	-sOutputFile=|lpr instead of outputting to -.  (I am run-
	ning GhostScript in a printer filter.)


	Another workaround should be to do this:

	grep -v '^\(%%\[ .*Page.* \]%%\).*=$'

	...as a preprocessor to GhostScript.  This is a bit of a
	hack, but should work and should keep my lpd pipelines
	from being further abused by quirks.
>Release-Note:
>Audit-Trail:
>Unformatted: