JDK-4863795 : Intermittent Invalid Profile Data exception ColorSpace.GetInstance
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.3.1,1.4.1
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2003-05-14
  • Updated: 2006-02-27
  • Resolved: 2006-02-27
Related Reports
Duplicate :  
Description
Name: dk106046			Date: 05/14/2003

JDK: 1.3.1, 1.4, 1.4.1.

Exact Steps to Reproduce:

      The problem is intermittent / timing related
      Run any code that calls causes ColorSpace.getInstance to be called
      from multiple threads, and it will happen eventually.

Exact Text of error message:

         java.awt.color.CMMException: Invalid profile data
         java/lang/Throwable.<init>(Ljava/lang/String;)V+4
(Throwable.java:90)
         java/lang/Exception.<init>(Ljava/lang/String;)V+1
(Exception.java:38)
         java/lang/RuntimeException.<init>(Ljava/lang/String;)V+1
(RuntimeException.java:43)
         sun/awt/color/CMM.checkStatus(I)V+12 (CMM.java:121)
         java/awt/color/ICC_ColorSpace.toRGB([F)[F+50
(ICC_ColorSpace.java:142)
         java/awt/image/DirectColorModel.getRGB(I)I+7
(DirectColorModel.java:399)

Code fix for JDK:

      Synchronize the code marked >>> synchronize <<< end synchronize.
      Potentially synchronize the whole getInstance method as the other
      elements of the case have the same logic (although have not seen
      actual bug happen).


  public static ColorSpace getInstance (int colorspace)
    {
    ColorSpace    theColorSpace;

        switch (colorspace) {
        case CS_sRGB:
            >>> synchronize 
            if (sRGBspace == null) {
                ICC_Profile theProfile = ICC_Profile.getInstance (CS_sRGB);
                sRGBspace = new ICC_ColorSpace (theProfile);
            }

            theColorSpace = sRGBspace;
            <<< End synchronize
            break;

        case CS_CIEXYZ:
            if (XYZspace == null) {
                ICC_Profile theProfile = ICC_Profile.getInstance
(CS_CIEXYZ);
                XYZspace = new ICC_ColorSpace (theProfile);
            }

            theColorSpace = XYZspace;
            break;

        case CS_PYCC:
            if (PYCCspace == null) {
                ICC_Profile theProfile = ICC_Profile.getInstance (CS_PYCC);
                PYCCspace = new ICC_ColorSpace (theProfile);
            }

            theColorSpace = PYCCspace;
            break;


        case CS_GRAY:
            if (GRAYspace == null) {
                ICC_Profile theProfile = ICC_Profile.getInstance (CS_GRAY);
                GRAYspace = new ICC_ColorSpace (theProfile);
            }

            theColorSpace = GRAYspace;
            break;


        case CS_LINEAR_RGB:
            if (LINEAR_RGBspace == null) {
                ICC_Profile theProfile =
ICC_Profile.getInstance(CS_LINEAR_RGB);
                LINEAR_RGBspace = new ICC_ColorSpace (theProfile);
            }

            theColorSpace = LINEAR_RGBspace;
            break;


        default:
            throw new IllegalArgumentException ("Unknown color space");
        }

        return theColorSpace;
    }

The JDK 1.4.1 version of java/awt/color/ColorSpace.java appears to have
exactly the same problem. Note also, that
java/awt/color/ICC_Profile.getInstance(int cspace) in both JDK 1.3.1 and
1.4.1 has the same potential multiple creation problem, but I have not yet
observed it to actually cause an observable problem if synchronization has
been implemented in ColorSpace.getInstance.

======================================================================

Comments
EVALUATION Looks like (according to the stack trace provided with this CR) this is the same problem that was fixed within 6245283. So, I'm closing this bug as duplicate. Please, reopen this bug with additional info provided if the crash appears again.
27-02-2006