Bug 692283

Summary: -sDefaultGrayProfile causes SEGV with tiff32nc device
Product: Ghostscript Reporter: Ken Sharp <ken.sharp>
Component: ColorAssignee: Alex Cherepanov <alex>
Status: NOTIFIED FIXED    
Severity: major CC: michael.vrhel
Priority: P1    
Version: master   
Hardware: PC   
OS: Windows Vista   
Customer: 850 Word Size: ---

Description Ken Sharp 2011-06-16 15:36:30 UTC
This command line:

gs -sDEVICE=tiff32nc -sDefaultGrayProfile=ps_gray.icc -sOutputFile=out.tif

causes a SEG fault in gx_remap_ICC because the tiff32nc device profile_array is NULL.

I'm not sure why, since the tiff24nc device works as expected.
Comment 1 Ken Sharp 2011-06-16 15:37:25 UTC
Upping to P1 for seg fault and customer problem.
Comment 2 Michael Vrhel 2011-06-16 19:06:08 UTC
OK.  I see the issue.  

In the interpreter we are doing a series of getdeviceparameters before procs.get_profile is set.  During times like that we do not set up the device profile since we are not ready yet.  See gx_default_get_params line 130

At some point the interpreter does a setdevice which ends up setting the procedure procs.get_profile.  At this point, we should do a getdeviceparameters so that we can get a profile set up.  But instead we do a fillpage.  Now it turns out that if we have not set -sDefaultGrayProfile the colorspace is still at this time DeviceGray and we use the DeviceGray colorspace procs for mapping the color.  If we have set -sDefaultGrayProfile then the color space is ICC and we use the ICC colorspace procs for mapping the fillpage color.  Problem is we have not set the device profile yet.  

The proper fix for this is to make sure that we do another getdeviceparameters after the setdevice occurs.  This will ensure that the device profile is set and in place.  

Punting off to Alex since this is done in the interpreter.
Comment 3 Michael Vrhel 2011-06-27 05:27:07 UTC
Fixed with http://git.ghostscript.com/?p=ghostpdl.git;a=commit;h=f4e1d4b280f6e6ff73d630e2b103a1a6b50c03d9

This amounted to moving the initialization of the icc manager and the device profile earlier in the whole start up process.