Bug 688584 - Segmentation fault and image corruption on duotone jobs
Summary: Segmentation fault and image corruption on duotone jobs
Status: NOTIFIED INVALID
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Graphics Library (show other bugs)
Version: 8.54
Hardware: Macintosh MacOS X
: P2 normal
Assignee: Timothy Osborn
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-06 10:13 UTC by Leonid Lukomskij
Modified: 2008-12-19 08:31 UTC (History)
0 users

See Also:
Customer: 582
Word Size: ---


Attachments
Prpblem file and halftone definitions (21.63 MB, application/octet-stream)
2006-03-06 10:16 UTC, Leonid Lukomskij
Details
this is rar archive (17.15 MB, application/octet-stream)
2007-05-07 12:44 UTC, Leonid Lukomskij
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Leonid Lukomskij 2006-03-06 10:13:29 UTC
I'm going to redefine halftone settings on some jobs. I create file setht.ps
containing nessessary halftone settings for CMYK+default (halftone dictionary
type 5). Most jobs goes OK.

But if I run duotone jobs I have segmentation fault:

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=spotcmyk -r1200x600 -sOutputFile=30294-%d
setht.ps 30294\ WW\ Spring\ 04.ps

I correct file setht.ps and remove CMY components from halftone dictionary. Job
runs OK and finishes:

gsc -dSAFER -dBATCH -dNOPAUSE -sDEVICE=spotcmyk -r1200x600 -sOutputFile=30294-%d
setht1.ps 30294\ WW\ Spring\ 04.ps

But it seems that image on page 8 is corrupted. See resulting .pcx file

Leonid Lukomskij
Comment 1 Leonid Lukomskij 2006-03-06 10:16:58 UTC
Created attachment 2078 [details]
Prpblem file and halftone definitions
Comment 2 Raph Levien 2006-03-22 11:43:08 UTC
This is working for me with current SVN version, with both setht.ps and
setht1.ps. Please reopen if you are able to reproduce the error with a current
version of Ghostscript.
Comment 3 Leonid Lukomskij 2006-09-19 11:28:52 UTC
Does not work for me with version 8.54 under the same conditions. Please, 
check, this cam be macosx-specific issue. 
Comment 4 Leonid Lukomskij 2006-11-29 10:38:15 UTC
I'd like to confirm bug under the same conditions. I see corrupted image under 
linux too.

Lucid Dream has license agreement with Artifex now. So I hope that this bug 
will be resolved.
Comment 5 Andreas Vox 2007-03-12 10:23:59 UTC
I can confirm this bug running AFPL Ghostscript 8.54 on my PowerBook. It gives
the attached crashreport. 
Output is:

gsc -dSAFER -dBATCH -dNOPAUSE -sDEVICE=spotcmyk -r1200x600 -sOutputFile=30294-%d
setht.ps 30294\ WW\ Spring\ 04.ps 
AFPL Ghostscript 8.54 (2006-05-17)
Copyright (C) 2005 artofcode LLC, Benicia, CA.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Loading NimbusSanL-Bold font from
/Library/Frameworks/Ghostscript.framework/Resources/fonts/n019004l.pfb...
2700336 1015639 3445396 1780022 1 done.
Loading NimbusMonL-Regu font from
/Library/Frameworks/Ghostscript.framework/Resources/fonts/n022003l.pfb...
2717000 1120120 3766932 2463000 1 done.
Loading NimbusSanL-Regu font from
/Library/Frameworks/Ghostscript.framework/Resources/fonts/n019003l.pfb...
2733664 1197018 3987988 2687852 1 done.
Loading StandardSymL font from
/Library/Frameworks/Ghostscript.framework/Resources/fonts/s050000l.pfb...
2733664 1234320 4470292 3120477 1 done.
Segmentation fault



The followinf files are created:

vox$ ls -l 30294*
-rwx------   1 vox  staff  36342791 Mar 25  2005 30294 WW Spring 04.ps
-rw-r--r--   1 vox  staff  11550000 Mar 12 18:19 30294-%ds0
-rw-r--r--   1 vox  staff   3571934 Mar 12 18:19 30294-%ds0.pcx
-rw-r--r--   1 vox  staff  11550000 Mar 12 18:19 30294-%ds1
-rw-r--r--   1 vox  staff   2713099 Mar 12 18:19 30294-%ds1.pcx
-rw-r--r--   1 vox  staff         0 Mar 12 18:14 30294-1
-rw-r--r--   1 vox  staff         0 Mar 12 18:15 30294-2
-rw-r--r--   1 vox  staff         0 Mar 12 18:18 30294-3



Crashreport:


Date/Time:      2007-03-12 18:20:01.416 +0100
OS Version:     10.4.8 (Build 8L127)
Report Version: 4

Command: gsc
Path:    /Library/Frameworks/Ghostscript.framework/bin/gsc
Parent:  bash [5478]

Version: ??? (???)

PID:    5498
Thread: 0

Exception:  EXC_BAD_ACCESS (0x0001)
Codes:      KERN_INVALID_ADDRESS (0x0001) at 0xbf000104

Thread 0 Crashed:
0   com.ghostscript.Ghostscript 	0x0130f3b8 set_color_ht_le_4 + 2492
1   com.ghostscript.Ghostscript 	0x0130b6a0 gx_dc_ht_colored_fill_rectangle + 2540
2   com.ghostscript.Ghostscript 	0x01339a8c image_render_mono + 9024
3   com.ghostscript.Ghostscript 	0x013321b4 gx_image1_plane_data + 2756
4   com.ghostscript.Ghostscript 	0x01335c38 gx_image_plane_data_rows + 76
5   com.ghostscript.Ghostscript 	0x012e759c gs_image_next_planes + 1572
6   com.ghostscript.Ghostscript 	0x011077ec image_proc_continue + 448
7   com.ghostscript.Ghostscript 	0x010c7a40 interp + 3992
8   com.ghostscript.Ghostscript 	0x010c5e54 gs_call_interp + 328
9   com.ghostscript.Ghostscript 	0x010c5c9c gs_interpret + 120
10  com.ghostscript.Ghostscript 	0x010b8080 gs_main_interpret + 1076
11  com.ghostscript.Ghostscript 	0x010b8f60 gs_main_run_string_end + 84
12  com.ghostscript.Ghostscript 	0x010b8d80 gs_main_run_string_with_length + 180
13  com.ghostscript.Ghostscript 	0x010b8cb0 gs_main_run_string + 80
14  com.ghostscript.Ghostscript 	0x010bc154 run_string + 64
15  com.ghostscript.Ghostscript 	0x010bc0dc runarg + 352
16  com.ghostscript.Ghostscript 	0x010bbd88 argproc + 196
17  com.ghostscript.Ghostscript 	0x010ba5c0 gs_main_init_with_args + 964
18  com.ghostscript.Ghostscript 	0x010be408 gsapi_init_with_args + 96
19  gsc                         	0x00002b84 main + 128 (dxmainc.c:84)
20  gsc                         	0x000024b0 _start + 392 (crt.c:267)
21  dyld                        	0x8fe01048 _dyld_start + 60

Thread 0 crashed with PPC Thread State 64:
  srr0: 0x000000000130f3b8 srr1: 0x000000000200f030                       
vrsave: 0x0000000000000000
    cr: 0x44000424          xer: 0x0000000000000005   lr: 0x000000000130eb2c 
ctr: 0x000000000130f1e0
    r0: 0x00000000bf0000f9   r1: 0x00000000bfffbbc0   r2: 0x00000000bf000101  
r3: 0x0000000000000001
    r4: 0x00000000bfffbc38   r5: 0x0000000000339960   r6: 0x0000000000001fb5  
r7: 0x0000000000000db9
    r8: 0x0000000000000001   r9: 0x00000000bfffc198  r10: 0x00000000bfffbc38 
r11: 0x00000000bf0000f9
   r12: 0x000000000130e9fc  r13: 0x0000000000000000  r14: 0x0000000000000000 
r15: 0x0000000000000000
   r16: 0x0000000000000000  r17: 0x0000000000000000  r18: 0x0000000000000000 
r19: 0x0000000000000000
   r20: 0x0000000000000000  r21: 0x0000000000000000  r22: 0x0000000000000000 
r23: 0x0000000000000000
   r24: 0x0000000000000000  r25: 0x0000000000000000  r26: 0x00000000bffff394 
r27: 0x0000000000000028
   r28: 0x0000000000000009  r29: 0x000000000183ed08  r30: 0x00000000bfffbbc0 
r31: 0x000000000130ea14

Binary Images Description:
    0x1000 -     0x2fff gsc 	/Library/Frameworks/Ghostscript.framework/bin/gsc
 0x1008000 -  0x13b2fff com.ghostscript.Ghostscript 703 (???)
/Library/Frameworks/Ghostscript.framework/Ghostscript
0x8f3ae000 - 0x8f3f0fff libXt.6.dylib 	/usr/X11R6/lib/libXt.6.dylib
0x8f612000 - 0x8f6ddfff libX11.6.dylib 	/usr/X11R6/lib/libX11.6.dylib
0x8f70a000 - 0x8f715fff libXext.6.dylib 	/usr/X11R6/lib/libXext.6.dylib
0x8f92c000 - 0x8f931fff libSM.6.dylib 	/usr/X11R6/lib/libSM.6.dylib
0x8f935000 - 0x8f944fff libICE.6.dylib 	/usr/X11R6/lib/libICE.6.dylib
0x8fe00000 - 0x8fe51fff dyld 45.3	/usr/lib/dyld
0x90000000 - 0x901bcfff libSystem.B.dylib 	/usr/lib/libSystem.B.dylib
0x90214000 - 0x90219fff libmathCommon.A.dylib 	/usr/lib/system/libmathCommon.A.dylib
0x9110d000 - 0x9111bfff libz.1.dylib 	/usr/lib/libz.1.dylib
Comment 6 Ray Johnston 2007-04-12 11:53:34 UTC
Adjusting priority to reflect customer bug  
Comment 7 Timothy Osborn 2007-04-23 15:02:10 UTC
When I run the file here with the latest gs build I receive a PostScript error.
Perhaps the file is corrupt or I'm not using the correct parameters as Distiller
returns similar results. My parameters and output follow:

-dSAFER -dBATCH -dNOPAUSE -sDEVICE=spotcmyk -r1200x600 -sOutputFile=30294-%d
~/setht.ps ~/30294WWSpring04.ps

and:

-dSAFER -dBATCH -dNOPAUSE -sDEVICE=spotcmyk -r1200x600 -sOutputFile=30294-%d
~/setht1.ps ~/30294WWSpring04.ps

(same results with either command).

Copyright (C) 2007 artofcode LLC, Benicia, CA.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Loading NimbusSanL-Bold font from
/usr/local/share/ghostscript/fonts/n019004l.pfb... 2590908 1039129 3445396
1816266 1 done.
Loading NimbusMonL-Regu font from
/usr/local/share/ghostscript/fonts/n022003l.pfb... 2627668 1159271 3847316
2539844 1 done.
Loading NimbusSanL-Regu font from
/usr/local/share/ghostscript/fonts/n019003l.pfb... 2664428 1255152 4068372
2767579 1 done.
Loading StandardSymL font from
/usr/local/share/ghostscript/fonts/s050000l.pfb... 2684524 1209773 4530580
2800365 1 done.
Error: /unmatchedmark in --cleartomark--
Operand stack:
   5   --nostringval--   false
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--  
--nostringval--   2   %stopped_push   --nostringval--   --nostringval--  
--nostringval--   false   1   %stopped_push   1797   1   3   %oparray_pop   1796
  1   3   %oparray_pop   1792   1   3   %oparray_pop   1675   1   3  
%oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--  
--nostringval--   --nostringval--   2   %stopped_push   --nostringval--  
--nostringval--   --nostringval--   %loop_continue   --nostringval--
Dictionary stack:
   --dict:1085/1123(ro)(G)--   --dict:1/20(G)--   --dict:90/200(L)--  
--dict:217/296(L)--   --dict:325/400(L)--
Current allocation mode is local
Last OS error: 2
Current file position is 14481826
GPL Ghostscript SVN PRE-RELEASE 8.57: Unrecoverable error, exit code 1
Comment 8 Timothy Osborn 2007-05-03 08:52:39 UTC
I retried this with both CPSI, gs on MacOSX (10.4.9) and AD8.0. For gs on OSX I
reported earlier the results I was getting (see my posting of 04-23-07 ). For
CPSI I get the following:

File: 30294WWSpring04.ps
Writing 5100 * 6600 pixels to myfile.tif ... 
done.
Writing 5100 * 6600 pixels to myfile.tif2 ... 
done.
Writing 5100 * 6600 pixels to myfile.tif3 ... 
done.
%%[ Error: undefined; OffendingCommand: K ]%%
%%[ Flushing: rest of job (to end-of-file) will be ignored ]%%

With AD 8.0 I get the following results:

Acrobat Distiller 8.0.0
Started: Thursday, May 3, 2007 at 11:50 AM
Adobe PostScript software version: 3016.102
CID support library initialization completed.

Distilling: 30294WWSpring04.ps
Start Time: Thursday, May 3, 2007 at 11:50 AM
Source: /Volumes/WD160/Artifex/Artifex-BUGS/688584/30294WWSpring04.ps
Destination: /Volumes/WD160/Artifex/Artifex-BUGS/688584/30294WWSpring04.pdf
Adobe PDF Settings: /Users/timothyosborn/Library/Application Support/Adobe/Adobe
PDF/Settings/Standard(1).joboptions
%%[ Error: undefined; OffendingCommand: K ]%%

Stack:
-mark-
-save-
5


%%[ Flushing: rest of job (to end-of-file) will be ignored ]%%
%%[ Warning: PostScript error. No PDF file produced. ] %%
Distill Time: 36 seconds (00:00:36)
**** End of Job ****

Neither PhotoShop or Apple Preview will open this file. This file appears to be
invalid.

Please correct the file and resubmit the bug report if you still have this problem.
Comment 9 Alex Cherepanov 2007-05-03 19:10:11 UTC
Ghostscript 8.54 has a bunch of crash severity bugs on 64-bit platforms.
There's no known 64-bit specific bugs in v, 8.56. Please upgrade.
Comment 10 Leonid Lukomskij 2007-05-07 12:17:35 UTC
I downloaded file from your server. It is corrupted. I tried original file with
gs 8.56. It finished with ps error:

 Error: /unmatchedmark in --cleartomark-- 

like in your post from 2007-04-23 15:02. So, I think, it was corrupted later. I
upload correct file. AD8 interprets it excellent.

I reopened bug. I don't understand why it was marked as resolved.
Comment 11 Leonid Lukomskij 2007-05-07 12:44:39 UTC
Created attachment 2938 [details]
this is rar archive
Comment 12 Timothy Osborn 2007-05-08 08:29:33 UTC
The newly uploaded file looks to be valid yet still produces an /unmatchedmark
--cleartomark-- error.
Comment 13 Timothy Osborn 2007-05-08 12:59:53 UTC
At this point what I know is that the /unmatchedmark in --cleartomark-- is the
result of a bogus colorspace that Adobe uses to test if some Pantone colors are
known to the device or not. This was fixed earlier as noted in bug report #549307.

Once I get past this issue I will be able to investigate the original report.
Comment 14 leonardo 2007-05-16 13:48:18 UTC
Updated info from Leonid :

[beg quote]
1) I marked old attachment as obsolete. It was corrupted after it was 
uploaded to bugzilla (I don't know while, it was ok during first few 
months). New attachment is packed via WinRAR, it should be ok. It 
contains **my** file.

2) Files setht.ps and setht1.ps are has no sense now. They contain some 
halftone definitions. I found the problem using these files and I'm 
going to try to to return to them when problem will be solved.

3) Exact command line is:

bin\gswin32c.exe -I./lib -dSAFER -dBATCH -dNOPAUSE -sDEVICE=spotcmyk 
-r300 -sOutputFile=30 "30294 WW Spring 04.ps"

It creates file 30s0.pcx containing corrupted image

GPL Ghostscript SVN PRE-RELEASE 8.60 (2007-05-12)

Compiler is MSVC 8.0

Environment:

ALLUSERSPROFILE=C:\Documents and Settings\All Users.WINDOWS
APPDATA=C:\Documents and Settings\leonidas.LEONEWNOTEBOOK\Application Data
APR_ICONV_PATH=C:\Program Files\Subversion\iconv
COMMANDER_DRIVE=C:
COMMANDER_INI=C:\tc\wincmd.ini
COMMANDER_PATH=C:\tc
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=LEONEWNOTEBOOK
ComSpec=C:\WINDOWS\system32\cmd.exe
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Documents and Settings\leonidas.LEONEWNOTEBOOK
INFOPATH=c:\MinGW\info;c:\GnuWin32\info
LANG=C
LOGONSERVER=\\LEONEWNOTEBOOK
NUMBER_OF_PROCESSORS=2
OS=Windows_NT
Path=C:\Program Files\MiKTeX 
2.6\miktex\bin;C:\Perl\site\bin;C:\Perl\bin;c:\prog
ram 
files\imagemagick-6.3.2-q16;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System
32\Wbem;C:\PROGRA~1\cvsnt;C:\Program Files\Common Files\Lucid 
Dream;C:\I-Trap\I-
Trap;C:\Program Files\Common Files\GTK\2.0\bin;C:\Program 
Files\Subversion\bin;C
:\Program Files\Common Files\Adobe\AGL;c:\xindydos;c:\Program 
Files\PuTTY;c:\Pro
gram Files\Common Files\ISpell;c:\Program 
Files\mplayer;c:\MinGW\bin;c:\Qt\4.2.3
\bin;c:\cygwin\usr\local\bin;c:\GnuWin32\bin
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 6 Model 14 Stepping 8, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=0e08
ProgramFiles=C:\Program Files
PROMPT=$P$G
QTDIR=c:\Qt\4.2.3
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\WINDOWS
TEMP=C:\DOCUME~1\LEONID~1.LEO\LOCALS~1\Temp
TMP=C:\DOCUME~1\LEONID~1.LEO\LOCALS~1\Temp
USERDOMAIN=LEONEWNOTEBOOK
USERNAME=leonidas
USERPROFILE=C:\Documents and Settings\leonidas.LEONEWNOTEBOOK
VS80COMNTOOLS=C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\
windir=C:\WINDOWS
WXWIN=c:\wxWidgets-2.8.3

4) I applied patch from Tim. So it goes without unmatchedmark error. I 
attached patch applied.
But this file still fails with tiffg4 (and other 1-bit devices). Error: 
/rangecheck in --image--

Tim, I compiled 8.60 on mac. Image is correct with -r300 and corrupted 
with -r1200.

So, I think, this bug depends on resolution.

Best regards

Leonid
[end quote]

[patch beg]
Index: lib/gs_devn.ps
===================================================================
--- lib/gs_devn.ps      (revision 7904)
+++ lib/gs_devn.ps      (working copy)
@@ -200,10 +200,13 @@
       {
         .usealternate
           {
-            pop currentcolor
+            pop
+            mark true
+            currentcolor
             currentcolorspace 3 get exec
             currentcolorspace 2 get
             //clear_setcolor_operands exec
+            cleartomark
           }
           { pop }
         ifelse

[patch end]
Comment 15 leonardo 2007-05-27 11:06:11 UTC
Patch to HEAD :
http://ghostscript.com/pipermail/gs-cvs/2007-May/007586.html

This patch fixes a different problem than one reported, but it is neccessary to 
run the test document. It is an improved revision of the patch from Comment #14.

As we figured out with an addinional mailing, the user considered images to be 
wrong because he wrongly understood the purpose of spotcmyk device. Due to that 
we close the bug as invalid. In same we add the test case to comparefiles 
becausae it proves the necessity of the patch.