Bug 1926633

Summary: NullPointerException from java.awt.color.ICC_Profile in multi-thread application
Product: Red Hat Enterprise Linux 8 Reporter: kazuhiro kawana <kkawana>
Component: java-11-openjdkAssignee: Andrew John Hughes <ahughes>
Status: CLOSED CURRENTRELEASE QA Contact: OpenJDK QA <java-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.3CC: ahughes
Target Milestone: rc   
Target Release: 8.9   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: java-11-openjdk-11.0.16.0.8-1.el8_4 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-30 07:50:15 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description kazuhiro kawana 2021-02-09 09:13:25 UTC
### Description of problem:
We got NullpointerException from java.awt.color.ICC_Profile using openjdk11 and openjdk 1.8.0.

A same issue was reported in JDK bug database and already fixed:

Fixed bug: 
https://bugs.openjdk.java.net/browse/JDK-6986863

Related bug:
https://bugs.openjdk.java.net/browse/JDK-8058973
https://bugs.openjdk.java.net/browse/JDK-8254737

It looks OpenJDK 11(latest) and OpenJDK 1.8.0(latest) does not contain the above fix. Please a backport the fix.

### Version-Release number of selected component (if applicable):
- java-11-openjdk-11.0.10.0.9-4.el8_3.x86_64
- java-1.8.0-openjdk-1.8.0.282.b08-2.el8_3.x86_64

### How reproducible:

Anytime

### Steps to Reproduce:
1: Install latest openjdk 11 or openjdk 1.8.0: 

I installed openjdk 11 or openjdk 1.8.0.

2: Comple sample code "MTInitCMM.java"

===
# cat MTInitCMM.java
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 {
        ICC_ProfileRGB 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();
        }
    }
}
===

We use sample code in the following url.
https://bugs.openjdk.java.net/browse/JDK-8254737

3: Comple sample code “MTInitCMM.java” :

4: Run sample code MTInitCMM.java:

### Actual results:

You can see NullpointerException.

Java11 Latest
# /usr/lib/jvm/java-11-openjdk-11.0.10.0.9-4.el8_3.x86_64/bin/javac -cp ./ MTInitCMM.java
# /usr/lib/jvm/java-11-openjdk-11.0.10.0.9-4.el8_3.x86_64/bin/java MTInitCMM
Exception in thread "Thread-0" java.lang.NullPointerException
    at java.desktop/java.awt.color.ICC_Profile.intFromBigEndian(ICC_Profile.java:1763)
    at java.desktop/java.awt.color.ICC_Profile.getXYZTag(ICC_Profile.java:1563)
    at java.desktop/java.awt.color.ICC_ProfileRGB.getMatrix(ICC_ProfileRGB.java:161)
    at MTInitCMM.lambda$main$0(MTInitCMM.java:19)
    at java.base/java.lang.Thread.run(Thread.java:834)
...snip...

Java8 Latest
# /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.282.b08-2.el8_3.x86_64/bin/javac -cp ./ MTInitCMM.java
# /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.282.b08-2.el8_3.x86_64/bin/java MTInitCMM
Exception in thread "Thread-68" java.lang.NullPointerException
    at java.awt.color.ICC_Profile.intFromBigEndian(ICC_Profile.java:1767)
    at java.awt.color.ICC_Profile.getXYZTag(ICC_Profile.java:1567)
    at java.awt.color.ICC_ProfileRGB.getMatrix(ICC_ProfileRGB.java:161)
    at MTInitCMM.lambda$main$0(MTInitCMM.java:19)
    at java.lang.Thread.run(Thread.java:748)
...snip...

### Expected results:
We expect processed normally using openjdk11 or openjdk1.8.0.

Comment 2 kazuhiro kawana 2023-05-30 07:50:15 UTC
I have confirmed that this bug is fixed on OpenJDK 11.0.16.

  26 New in release OpenJDK 11.0.16 (2022-07-19):
  27 =============================================
  28 Live versions of these release notes can be found at:
  29   * https://bitly.com/openjdk11016
  30   * https://builds.shipilev.net/backports-monitor/release-notes-11.0.16.txt
  31
  32 * Security fixes
  33   - JDK-8277608: Address IP Addressing
  34   - JDK-8272243: Improve DER parsing
  35   - JDK-8272249: Better properties of loaded Properties
  36   - JDK-8281859, CVE-2022-21540: Improve class compilation
  37   - JDK-8281866, CVE-2022-21541: Enhance MethodHandle invocations
  38   - JDK-8283190: Improve MIDI processing
  39   - JDK-8284370: Improve zlib usage
  40   - JDK-8285407, CVE-2022-34169: Improve Xalan supports
  41 * Other changes
  42   - JDK-6986863: ProfileDeferralMgr throwing ConcurrentModificationException <------ fixed bug.

So, I closed this case.