Bug 688048 - ijs driver broken in 8.51 for ProcessColorModel=Gray versus 8.50
Summary: ijs driver broken in 8.51 for ProcessColorModel=Gray versus 8.50
Status: NOTIFIED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Other Driver (show other bugs)
Version: master
Hardware: PC All
: P2 normal
Assignee: Dan Coby
URL:
Keywords:
: 688135 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-04-20 23:07 UTC by Hin-Tak Leung
Modified: 2008-12-19 08:31 UTC (History)
2 users (show)

See Also:
Customer:
Word Size: ---


Attachments
patch to set a large char array. (495 bytes, patch)
2005-04-21 17:47 UTC, Hin-Tak Leung
Details | Diff
trimmed version of Dan's diff to address the segfault (620 bytes, patch)
2005-04-22 18:01 UTC, Hin-Tak Leung
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hin-Tak Leung 2005-04-20 23:07:41 UTC
I just upgraded to 8.51 from 8.50 and epsonepl has stopped 
working with ghostscript segfaulting. I have tried
removing the usual switches and gs 8.51 seems
not to like "-sProcessColorModel=DeviceGray".

It looks like the "fix" for bug 687013 had broken
Gray devices - 

http://bugs.ghostscript.com/show_bug.cgi?id=687013

Am I being paranoid or that "gs_malloc(ijsdev->memory, sizeof(rgb), 1,..."
line being obviously wrong? ('DeviceGray' is one character
longer than 'DeviceRGB').
Comment 1 Hin-Tak Leung 2005-04-21 00:35:29 UTC
changing the malloc "sizeof(rgb)" to "sizeof(rgb) +2" doesn't 
help - still segfault;
but that's the only change in gdevijs. Need to look further...
Comment 2 Hin-Tak Leung 2005-04-21 01:51:39 UTC
Sorry, I was right at the very beginning - the "fix" for bug 687013
is the problem. There are two ways of making it work without breaking
the ijs driver for gray devices, 

one is changing "sizeof(rgb)"
in *both* "gs_malloc(ijsdev->memory, sizeof(rgb), 1,..."
and "ijsdev->ColorSpace_size = sizeof(rgb);" to a larger
number (+2 would do),

the other is to preallocate the rgb string to a bigger storage.i.e.
from

    "static const char rgb[] = "DeviceRGB";"

   "static const char rgb[11] = "DeviceRGB";"

Either of these approaches avoid the segfault.
Comment 3 Hin-Tak Leung 2005-04-21 17:46:01 UTC
Rewording title. I have opted for a larger char array myself:


--- src/gdevijs.c~      2005-04-21 09:45:29.000000000 +0100
+++ src/gdevijs.c       2005-04-21 10:02:30.000000000 +0100
@@ -813,7 +813,8 @@
 gsijs_finish_copydevice(gx_device *dev, const gx_device *from_dev)
 {
     int code;
-    static const char rgb[] = "DeviceRGB";
+    /* Need to be big enough to hold DeviceCMYK, DeviceGray as well */
+    static const char rgb[11] = "DeviceRGB";
     gx_device_ijs *ijsdev = (gx_device_ijs *)dev;
 
     code = gx_default_finish_copydevice(dev, from_dev);
Comment 4 Hin-Tak Leung 2005-04-21 17:47:47 UTC
Created attachment 1329 [details]
patch to set a large char array.

patch to set a large array as described to contain
DeviceGray/CMYK, plus comment explaining so.
Comment 5 Dan Coby 2005-04-22 14:43:24 UTC
Hin-Tak Leung,

Thank you for your efforts with this problem.  However I think that your patch 
is hiding the real problem which is with the str parameter in the call to 
gs_free at line 983.

More information on my version of the fix at:  
http://ghostscript.com/pipermail/gs-code-review/2005-April/004783.html

Comment 6 Dan Coby 2005-04-22 15:04:02 UTC
Note:  For anyone that wants to reproduce this problem on Windows, Russell 
Lang was nice enough to provide a command line:

bin/gswin32c.exe  -sDEVICE=ijs -sIjsServer=ijs\ijs_server_example.exe -
dProcessColorModel=/DeviceGray -dBATCH -dNOPAUSE -sOutputFile=out.ps 
examples/colorcir.ps
Comment 7 Hin-Tak Leung 2005-04-22 18:01:25 UTC
Created attachment 1331 [details]
trimmed version of Dan's diff to address the segfault

Had a good look at Dan's diff, and saw most of it was
white-space change and adding line-breaks; isolated
the important pointer fix.

Already patched my ghostscript again and verified
that this patch works.
Comment 8 Dan Coby 2005-04-26 14:31:03 UTC
The fix is described in:

http://ghostscript.com/pipermail/gs-cvs/2005-April/005490.html

Note:  This does include the removal of the extra ^M at the end of lines.  
These were placed there by a previous patch from Alex.
Comment 9 Barry Kauler 2005-06-13 23:41:59 UTC
*** Bug 688135 has been marked as a duplicate of this bug. ***