Bug 689323 - bjc600's gs_closedevice breaks get_page_device and causes NumCopies to barf
Summary: bjc600's gs_closedevice breaks get_page_device and causes NumCopies to barf
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Printer Driver (show other bugs)
Version: master
Hardware: All All
: P4 normal
Assignee: Till Kamppeter
URL: http://www.cups.org/str.php?L1577
Depends on:
Blocks: 689315
  Show dependency tree
Reported: 2007-07-04 05:27 UTC by Till Kamppeter
Modified: 2008-12-19 08:31 UTC (History)
0 users

See Also:
Word Size: ---

Fix of bjc600 output device (2.07 KB, patch)
2007-07-04 05:28 UTC, Till Kamppeter
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Till Kamppeter 2007-07-04 05:27:45 UTC


In gs-esp 8.15.1, the following PostScript file
 /NumCopies 1
 /Policies <<
 /PolicyNotFound 1
 >> setpagedevice
fed to the following rune
-dBitsPerPixel=24 -dProcessColorModel=/DeviceCMYK -sOutputFile=t bad.ps
causes this error
 Error: /undefined in --setpagedevice--

This is because:
 gx_default_put_params checks whether get_page_device works, before attempting
to process the NumCopies pagedevice setting
 gdevcdj uses gdevprn and all prn devices are page devices so get_page_device
should be gx_page_device_get_page_device, and indeed gdevprn sets it like that
 cdj_set_bpp calls gs_closedevice which calls gdev_prn_tear_down which restores
a set of procs including gx_default_get_page_device so that the check fails.

This causes gx_default_put_params not to read the NumCopies parameter, so that
it is left unread, and then an error is later issued by ref_param_read_commit
because the relevants ->results[] entry is still zero.

I don't know whether the bug is:
 * that iplist->u.r.require_all is set on entry to ref_param_read_commit
 * that cdj_set_bpp calls gs_closedevice
 * that gdev_prn_tear_down restores the procedures
 * the check in gx_default_put_params

This bug was reported by an Ubuntu user in our bug system, at

I need to decide what to do about this for our release.  It causes some files
not to be printable on bjc600's.  As a straightforward change which will
probably have relatively low and benign impact, unless I hear otherwise in time
I will probably arrange for our forthcoming release's gs-esp's
gx_default_put_params to always read the NumCopies parameter.

Thanks for your attention.

A patch to fix this is attached.
Comment 1 Till Kamppeter 2007-07-04 05:28:50 UTC
Created attachment 3142 [details]
Fix of bjc600 output device
Comment 2 Ray Johnston 2007-07-10 09:36:25 UTC
The patch looks fine. Please commit. 
Comment 3 Till Kamppeter 2007-07-10 10:16:36 UTC
Fixed in revision 8113.