JDK-8254737 : The sun.java2d.cmm.ProfileDeferralMgr class is not thread safe
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 11,16
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2020-10-14
  • Updated: 2020-11-13
  • Resolved: 2020-11-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdResolved
Related Reports
Duplicate :  
Relates :  
Description
Accidentally caught the suspicious exception that the reference to the CMM profile is null. Looks like the problem is in the deferral machinery it does not thread-safe:
The test which always triggers this bug:

import java.awt.color.ColorSpace;
import java.awt.color.ICC_Profile;
import java.awt.color.ICC_ProfileRGB;
import java.util.concurrent.CountDownLatch;

public final class MTInitCMM {

    public static void main(String[] args) throws Exception {
        var rgb = (ICC_ProfileRGB) ICC_Profile.getInstance(ColorSpace.CS_sRGB);
        Thread[] threads = new Thread[100];
        CountDownLatch go = new CountDownLatch(1);
        for (int i = 0; i < threads.length; i++) {
            threads[i] = new Thread(() -> {
                try {
                    go.await();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                rgb.getMatrix();
            });
        }
        for (Thread thread : threads) {
            thread.start();
        }
        go.countDown();
        for (Thread thread : threads) {
            thread.join();
        }
    }
}
==========
The output:
java.lang.NullPointerException: Cannot load from byte/boolean array because "array" is null
	at java.desktop/java.awt.color.ICC_Profile.intFromBigEndian(ICC_Profile.java:1741)
	at java.desktop/java.awt.color.ICC_Profile.getXYZTag(ICC_Profile.java:1542)
	at java.desktop/java.awt.color.ICC_ProfileRGB.getMatrix(ICC_ProfileRGB.java:149)
	at MTInitCMM.lambda$main$0(MTInitCMM.java:19)
	at java.base/java.lang.Thread.run(Thread.java:832)