-
Bug
-
Resolution: Duplicate
-
P4
-
11, 16
-
generic
-
generic
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)
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)
- duplicates
-
JDK-8058973 NullPointerException from ICC_Profile.getInstance() in multi-thread application
-
- Closed
-
- relates to
-
JDK-6793818 JpegImageReader is too greedy creating color profiles
-
- Closed
-