Bug 689065 - GhostScript segfaults on certain PostScript files when KRGB patch is applied
Summary: GhostScript segfaults on certain PostScript files when KRGB patch is applied
Status: NOTIFIED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PS Interpreter (show other bugs)
Version: master
Hardware: All Linux
: P4 normal
Assignee: Ralph Giles
URL: https://launchpad.net/ubuntu/+source/...
Keywords: bountiable
Depends on:
Blocks:
 
Reported: 2007-01-29 02:52 UTC by Till Kamppeter
Modified: 2008-12-19 08:31 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments
PostScript file which makes GhostScript segfaulting (288.74 KB, application/postscript)
2007-01-29 02:57 UTC, Till Kamppeter
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Till Kamppeter 2007-01-29 02:52:39 UTC
The attached PostScript file makes GPL GhostScript 8.54 segfaulting:

$ gs -q -dBATCH -dPARANOIDSAFER -dQUIET -dNOPAUSE -sDEVICE=ijs -sIjsServer=hpijs
-sDeviceManufacturer="HEWLETT-PACKARD" -sDeviceModel="DESKJET 930"
-dDEVICEWIDTHPOINTS=612 -dDEVICEHEIGHTPOINTS=792 -dDuplex=false -r300
-sIjsParams=Quality:Quality=0,Quality:ColorMode=0,Quality:MediaType=0,Quality:PenSet=2
-dIjsUseOutputFD -sOutputFile=- ~/fea19b.ps

The PostScript file is broken, as it does not print correctly when sent
unfiltered to a PostScript printer (HP LaserJet 3390), but GhostScript should
give an error message then instead of segfaulting.
Comment 1 Till Kamppeter 2007-01-29 02:57:15 UTC
Created attachment 2720 [details]
PostScript file which makes GhostScript segfaulting
Comment 2 Alex Cherepanov 2007-01-29 05:19:47 UTC
What happens when you run the file on other devices, for instance x11 ?

I didn't try ijs but the file runs OK on the display device with gs 8.54 and
the current HEAD.
Comment 3 Alex Cherepanov 2007-01-31 05:12:40 UTC
A bug that causes SEGV in garbage collection has been fixed in 
rev. 7658. Please check, whether the cuttent HEAD still crashes on your
box.
Comment 4 Hin-Tak Leung 2007-01-31 05:56:05 UTC
AFPL gs 8.54 displays x11 fine, but crashes with the ijs device as given.
I'll give trunk a try in a moment, but the crash is probably not as in comment 3.
Comment 5 Ray Johnston 2007-02-07 10:00:10 UTC
Thanks for the help, Hin-Tak
Comment 6 Till Kamppeter 2007-04-24 07:07:58 UTC
With the current SVN snapshot (revision 7879) it works for me.
Comment 7 Hin-Tak Leung 2007-04-24 09:35:37 UTC
I can confirm Till's comment regarding svn version 7879 ; interestingly 8.56
also segfaults; so I would suggest closing this either by testing again 
before the release of the next version, or on being able to find out
what caused the segfault.

I just have a thought - all my ghostscript versioned build have the 
krgb patch included (including comment #4, but excluding the svn build). 
I personally don't need it but I'd just like any issue to bite me first if 
it breaks epsonepl, rather than waiting for a user to report to me :-). 
Since it was Till filing the initial bug, the bug was probably filed against
a modified version of gs (at least for the initial launchpad report), not
clean-clean GPL 8.54?
  
Comment 8 Till Kamppeter 2007-04-24 09:58:54 UTC
The Ubuntu package of GPL GhostScript 8.54 has the KRGB patch, and this patch is
needed to fully support HP's inkjet printers. Simply dropping the KRGB patch is
not a solution. Perhaps the fix needs to be done in the patch?
Comment 9 Hin-Tak Leung 2007-04-24 10:28:16 UTC
I was not suggesting to take the patch out in comment 7, I was merely trying to
confirm that *every* one of the gs binaries has two things in common:
(1) they are all <= v8.56 (which we are sure of)
(2) have the KRGB patch applied - and you seem to have just confirmed it.

So one easy way of testing (2), at least for me, is to take the patch off my 
8.56 . If we can make sure it is (2), then we can concentration on the KRGB patch,
rather than (1) trying to find and confirm the svn version which fixed 
this segfault here, for example.

  
Comment 10 Till Kamppeter 2007-04-27 07:30:32 UTC
Working on the merger of ESP with GPL GhostScript I have built SVN recent
snapshots and they do nhot segfault. Today I have ported the KRGB patch which
comes with HPLIP to GPL GhostScript 8.57 and having built with the KRGB patch
the segfault occurs. So the problem seems for sure be caused by the KRGB patch.
Comment 11 Till Kamppeter 2007-06-28 05:03:31 UTC
I had e-mail conversation with David Suffield some time ago, and he thinks this
problem is a Ghostscript problem and not a problem of the KRGB patch. See his
mails below.

------------------------------------------------------------------------------

David Suffield wrote on 05/01/2007 04:52 PM:

Based on your feedback then this does sound like the same segfault
problem as the missing "-r" parameter. NO forward device (ie: no
ijsdev). The NULL check did not fix the missing "-r" segfault either,
the segfault just occurred somewhere else in the code. 

I still believe this is a up-stream gs problem.
===============================================

-dave

> > -----Original Message-----
> > From: Till Kamppeter [mailto:till.kamppeter@gmail.com] 
> > Sent: Monday, April 30, 2007 11:02 AM
> > To: Suffield, David
> > Cc: Yie, Shiyun; hintak_leung@yahoo.co.uk
> > Subject: Re: [HPLIP-Devel] KRGB patch for GhostScript causes segfault
> > 
> > Added the "ijsdev && " to the beginnings of the checks in the 
> > fill_rectangle and copy_mono functions but this did not help.
> > 
> > gs -q -dBATCH -dPARANOIDSAFER -dQUIET -dNOPAUSE -sDEVICE=ijs 
> > -sIjsServer=hpijs -sDeviceManufacturer="HEWLETT-PACKARD" 
> > -sDeviceModel="DESKJET 930" -dDEVICEWIDTHPOINTS=612
> > -dDEVICEHEIGHTPOINTS=792 -dDuplex=false -r300
> > -sIjsParams=Quality:Quality=0,Quality:ColorMode=0,Quality:Medi
> > aType=0,Quality:PenSet=2
> > -dIjsUseOutputFD -sOutputFile=- ~/printing/fea19b.ps
> > 
> > still segfaults.
> > 
> > I think the problem is that if ijsdev is NULL 
> > gsijs_fill_rectangle will directly run into
> > 
> > return (*ijsdev->prn_procs.fill_rectangle)(dev, x, y, w, h, color);
> > 
> > which causes the segfault now.
> > 
> > Same fore copy_mono. copy_mono will run into
> > 
> > return (*ijsdev->prn_procs.copy_mono)(dev, data, dx, draster, 
> > id, x, y, w, height, zero, one);
> > 
> > which also does not work with ijsdev == NULL.
> > 
> >     Till

------------------------------------------------------------------------------

David Suffield wrote on 04/30/2007 06:09 PM:

Yes, I realize (https://bugs.launchpad.net/gs-gpl/+bug/69905) is a
different, but the reason for the segfault could be the same.  

Please, give the suggested fix a try. This will tell me if it is the
same gs issue.

-dave

> > -----Original Message-----
> > From: Till Kamppeter [mailto:till.kamppeter@gmail.com] 
> > Sent: Friday, April 27, 2007 3:18 PM
> > To: Suffield, David
> > Cc: Yie, Shiyun; hintak_leung@yahoo.co.uk
> > Subject: Re: [HPLIP-Devel] KRGB patch for GhostScript causes segfault
> > 
> > Thanks for the information.
> > 
> > The problem here is also that in the command line in which 
> > the segfault was reported to Ubuntu there is a -r option:
> > 
> > gs -q -dBATCH -dPARANOIDSAFER -dQUIET -dNOPAUSE -sDEVICE=ijs 
> > -sIjsServer=hpijs -sDeviceManufacturer="HEWLETT-PACKARD" 
> > -sDeviceModel="DESKJET 930" -dDEVICEWIDTHPOINTS=612
> > -dDEVICEHEIGHTPOINTS=792 -dDuplex=false -r300
> > -sIjsParams=Quality:Quality=0,Quality:ColorMode=0,Quality:Medi
> > aType=0,Quality:PenSet=2
> > -dIjsUseOutputFD -sOutputFile=- ~/fea19b.ps
> > 
> > (https://bugs.launchpad.net/gs-gpl/+bug/69905)
> > 
> > The command line is generated by an HPIJS PPD file.
> > 
> > Is it a completely different bug then or can it be the same bug?
> > 
> >     Till
> > 
> > 

------------------------------------------------------------------------------

David Suffield wrote on 04/27/2007 11:09 PM:

Hi Till,

HP has assigned copyright of the KRGB patch to Artifex so they can use
the patch as they please. I guess what I'm trying to say is I'm not the
only owner of the patch anymore. I will do what I can, but ultimately it
is up to Artifex to make KRGB work in Ghostscript.

I have attached an email conversation I had with Hin-Tak about a
segfault that seemed to occur in the KRGB patch. If no "-r" parameter
was given on the gs command a segfault would occur. The reason for the
segfault was the forward device is not set (ie: "ijsdev = (gx_device_ijs
*)((gx_device_forward *)dev)->target"). I believe this is a up-stream gs
problem.

Why don't you go ahead and try the following NULL check in gdevijs.c. I
don't know if it will fix this problem, but it should at least the make
the KRGB code more bullet proof. 

The following null check can be added to fill_rectangle and copy_mono.
This will let the code default to the normal gs fill_rectangle/copy_mono
functions when there is no valid forward device.  

if (ijsdev && ijsdev->krgb_mode && ijsdev->k_path && y >= 0 && x >= 0) 

-dave

> > -----Original Message-----
> > From: hplip-devel-bounces@lists.sourceforge.net 
> > [mailto:hplip-devel-bounces@lists.sourceforge.net] On Behalf 
> > Of Till Kamppeter
> > Sent: Friday, April 27, 2007 7:45 AM
> > To: Suffield, David; Yie, Shiyun; dwelch91
> > Cc: hplip-devel@lists.sourceforge.net
> > Subject: [HPLIP-Devel] KRGB patch for GhostScript causes segfault
> > 
> > See
> > 
> > http://bugs.ghostscript.com/show_bug.cgi?id=689065
> > 
> > and
> > 
> > https://bugs.launchpad.net/hplip/+bug/69905
> > 
> > This segfault only happens when the KRGB patch is applied to 
> > GhostScript, otherwise not. So the bug must be in the KRGB patch.
> > 
> > I am currently merging ESP GhostScript into GPL GhostScript 
> > as Mike Sweet has closed the ESP GhostScript project. See
> > 
> > http://ghostscript.com/pipermail/gs-devel/2007-April/003414.html
> > 
> > and the additional patches on
> > 
> > http://www.linuxprinting.org/download/printing/esp-gpl-ghostsc
> > ript-merge/
> > 
> > There I have also posted an adapted KRGB patch:
> > 
> > http://www.linuxprinting.org/download/printing/esp-gpl-ghostsc
> > ript-merge/ghostscript-8.57-ijs-krgb.patch
> > 
> > Please do the fix on this one, as the further development of 
> > GhostScript happens exclusively based on the current 
> > Subversion state (GS 8.57).
> > 
> > Does someone of you have an account on bugs.ghostscript.com? 
> > If so, please tell me the account names.
> > 
> >     Till
> > 
> > --------------------------------------------------------------
> > -----------
> > This SF.net email is sponsored by DB2 Express Download DB2 
> > Express C - the FREE version of DB2 express and take control 
> > of your XML. No limits. Just data. Click to get it now.
> > http://sourceforge.net/powerbar/db2/
> > _______________________________________________
> > HPLIP-Devel mailing list
> > HPLIP-Devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/hplip-devel
> > 



From: Suffield, David
Sent: Thursday, November 16, 2006 10:53 AM
To: 'Hin-Tak Leung'
Cc: hplip
Subject: RE: ijs and krgb patch problem.

Hi Hin-Tak,
This has always been a problem with ghostscript/hpijs, if no "-r" is set the gs
command fails. This problem existed before the KRGB patch. Now with the KRGB
patch it happens to fail in the KRGB code. The work around has been to always
have "-r" set. This is the case with all the gs commands in our HPIJS PPD files. 

I have never looked into this problem, but based our your bug report for some
reason the forward device is not set (ie: "ijsdev = (gx_device_ijs
*)((gx_device_forward *)dev)->target"). I believe this is a up-stream gs problem.

One can make the KRGB code more bullet proof by checking for null pointer, but I
do not believe this will fix the no forward device issue.

The following null check can be added to fill_rectangle and copy_mono. The will
let the code default to the normal gs fill_rectangle/copy_mono functions when
there is no valid forward device.  

if (ijsdev && ijsdev->krgb_mode && ijsdev->k_path && y >= 0 && x >= 0) 

I have no problem adding this to the patch, but I don't consider it a high
priority given there is a work around.

-dave

> > -----Original Message-----
> > From: Hin-Tak Leung [mailto:hintak_leung@yahoo.co.uk]
> > Sent: Wednesday, November 15, 2006 4:07 PM
> > To: Suffield, David
> > Cc: hplip
> > Subject: Re: ijs and krgb patch problem.
> > 
> > 
> > Hi David,
> > 
> > Yes, the fill_rectangle/copy_mono part of KRGB code seems to be 
> > sensitive to with or without -r. (or maybe they get by-passed with 
> > -r?). I had a look, and "ijsdev = dev->target"
> > just doesn't seem to be initialized at all.
> > 
> > The initial bug report was about using hpijs with hp printer so it is 
> > right in your domain. As you probably know, most ghostscript problem 
> > triggered only by the ijs device doesn't get fixed or looked at until 
> > it can be reproduced with the example ijs server. It also happens that 
> > even my own-built GPL/AFPL gs have the KRGB patch - just so that if 
> > something breaks epsonepl I get to be first one to know:-).
> > 
> > Hin-Tak
> > 
> > Suffield, David wrote:
>> > > Hi Hin-Tak,
>> > > I to enjoyed our visit together in Kentucky. I appreciate your 
>> > > invitation, if I do make it to UK/London I would be glade
> > to give you
>> > > a call.
>> > > 
>> > > Looking at your bug report. There seems to be a KRGB sigfault if no 
>> > > "-r" is set in the gs command, is that correct?
>> > > 
>> > > For example this gs command fails in KRGB code:
>> > > 
>> > > /usr/bin/gs -sDEVICE=ijs -sIjsServer=ijs/ijs_server_example \ 
>> > > -dIjsUseOutputFD -sOutputFile=/tmp/fggg test-bug68891.ps
>> > > 
>> > > This gs command does not fail in KRGB code:
>> > > 
>> > > /usr/bin/gs -sDEVICE=ijs -sIjsServer=ijs/ijs_server_example \ 
>> > > -dIjsUseOutputFD -r300 -sOutputFile=/tmp/fggg test-bug68891.ps
>> > > 
>> > > -dave
> > Send instant messages to your online friends 
> > http://uk.messenger.yahoo.com
Comment 12 Ray Johnston 2007-06-28 08:29:53 UTC
Assigning to the default owner of the IJS device.

If this isn't an IJS issue, please assign back to support.
If the problem is traced into the graphics library or elsewhere, please assign
to that component 'owner'
Comment 13 Till Kamppeter 2008-01-23 06:23:27 UTC
HP has provided a fixed KRGB patch where this bug does not occur any more. I
have checked it and committed it to the Ghostscript SVN repository, rev 8497.