You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by Cornelis Hoeflake <c....@postex.com> on 2016/02/04 12:13:45 UTC

Random Exceptions in TestRendering

Hi,

I get a NPE when building the latest 2.0 code on Jenkins. Is someone else
getting the same errors?
The exception is mostly when executing the 4PP-Highlighting.pdf, but I have
it also seen in 26101_Colors.ai.
We run Jenkins on Linux and the problem occurs with Oracle JDK 1.8_45 and
Oracle JDK 1.8_72. On Windows I can reproduce it by using Oracle JDK 1.8_45
(no others tested).
The error occurs random, let us say 7 out of 10 times.

TestPDFToImage should also fail (because it is using the same path for
rendering), but that test is excluded. Why?

The exception occurs deep in Java and the NPE feels like a bug in the JVM.
Is the ColorSpace (at least ICC_Profile and ICC_ColorSpace) not thread safe
in Java (1.8)?

See stacktraces below.

Kind regards,
Cornelis Hoeflake


Stacktrace 1:
java.lang.NullPointerException: null
at java.awt.color.ICC_Profile.intFromBigEndian(ICC_Profile.java:1782)
at java.awt.color.ICC_Profile.getNumComponents(ICC_Profile.java:1474)
at sun.java2d.cmm.lcms.LCMSTransform.<init>(LCMSTransform.java:98)
at sun.java2d.cmm.lcms.LCMS.createTransform(LCMS.java:173)
at java.awt.color.ICC_ColorSpace.toRGB(ICC_ColorSpace.java:166)
at
org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB.init(PDDeviceRGB.java:69)
at
org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB.toRGB(PDDeviceRGB.java:103)
at org.apache.pdfbox.rendering.PageDrawer.getPaint(PageDrawer.java:237)
at
org.apache.pdfbox.rendering.PageDrawer.getNonStrokingPaint(PageDrawer.java:529)
at org.apache.pdfbox.rendering.PageDrawer.fillPath(PageDrawer.java:588)
at
org.apache.pdfbox.contentstream.operator.graphics.FillNonZeroRule.process(FillNonZeroRule.java:36)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:815)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:472)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:446)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.showForm(PDFStreamEngine.java:178)
at
org.apache.pdfbox.contentstream.operator.graphics.DrawObject.process(DrawObject.java:70)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:815)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:472)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:446)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:149)
at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:189)
at org.apache.pdfbox.rendering.PDFRenderer.renderPage(PDFRenderer.java:210)
at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:140)
at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:69)
at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:56)
at org.apache.pdfbox.rendering.TestRendering.render(TestRendering.java:79)

Stacktrace 2:

java.awt.color.CMMException: Unknown profile ID
at sun.java2d.cmm.lcms.LCMS.createTransform(LCMS.java:151)
at sun.java2d.cmm.lcms.LCMSTransform.doTransform(LCMSTransform.java:155)
at sun.java2d.cmm.lcms.LCMSTransform.colorConvert(LCMSTransform.java:629)
at java.awt.color.ICC_ColorSpace.toRGB(ICC_ColorSpace.java:182)
at
org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB.init(PDDeviceRGB.java:69)
at
org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB.toRGB(PDDeviceRGB.java:103)
at org.apache.pdfbox.rendering.PageDrawer.getPaint(PageDrawer.java:237)
at
org.apache.pdfbox.rendering.PageDrawer.getNonStrokingPaint(PageDrawer.java:529)
at org.apache.pdfbox.rendering.PageDrawer.fillPath(PageDrawer.java:588)
at
org.apache.pdfbox.contentstream.operator.graphics.FillNonZeroRule.process(FillNonZeroRule.java:36)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:815)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:472)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:446)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.showForm(PDFStreamEngine.java:178)
at
org.apache.pdfbox.contentstream.operator.graphics.DrawObject.process(DrawObject.java:70)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:815)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:472)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:446)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:149)
at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:189)
at org.apache.pdfbox.rendering.PDFRenderer.renderPage(PDFRenderer.java:210)
at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:140)
at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:69)
at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:56)
at org.apache.pdfbox.rendering.TestRendering.render(TestRendering.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Re: Random Exceptions in TestRendering

Posted by Cornelis Hoeflake <c....@postex.com>.
2016-02-25 18:00 GMT+01:00 Tilman Hausherr <TH...@t-online.de>:

> Am 04.02.2016 um 12:13 schrieb Cornelis Hoeflake:
>
>> Stacktrace 2:
>>
>> java.awt.color.CMMException: Unknown profile ID
>> at sun.java2d.cmm.lcms.LCMS.createTransform(LCMS.java:151)
>> at sun.java2d.cmm.lcms.LCMSTransform.doTransform(LCMSTransform.java:155)
>> at sun.java2d.cmm.lcms.LCMSTransform.colorConvert(LCMSTransform.java:629)
>> at java.awt.color.ICC_ColorSpace.toRGB(ICC_ColorSpace.java:182)
>>
>
> I got these too when running tests with JDK8. I changed this in the
> pom.xml of the PDFBox subproject:
>
> <argLine>-Xmx1024m</argLine>
>
> to
>
> <argLine>-Xmx1024m
> -Dsun.java2d.cmm=sun.java2d.cmm.kcms.KcmsServiceProvider</argLine>


Ok, but this error could also happen on products which are multithreaded
(webapp for example). So this system property has to be set on that
deployments too. I don't know if that is a good idea because this is a
global setting. And could influence other software parts.

Re: Random Exceptions in TestRendering

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 04.02.2016 um 12:13 schrieb Cornelis Hoeflake:
> Stacktrace 2:
>
> java.awt.color.CMMException: Unknown profile ID
> at sun.java2d.cmm.lcms.LCMS.createTransform(LCMS.java:151)
> at sun.java2d.cmm.lcms.LCMSTransform.doTransform(LCMSTransform.java:155)
> at sun.java2d.cmm.lcms.LCMSTransform.colorConvert(LCMSTransform.java:629)
> at java.awt.color.ICC_ColorSpace.toRGB(ICC_ColorSpace.java:182)

I got these too when running tests with JDK8. I changed this in the 
pom.xml of the PDFBox subproject:

<argLine>-Xmx1024m</argLine>

to

<argLine>-Xmx1024m 
-Dsun.java2d.cmm=sun.java2d.cmm.kcms.KcmsServiceProvider</argLine>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org


Re: Random Exceptions in TestRendering

Posted by Cornelis Hoeflake <c....@postex.com>.
Hi,

The stacktrace of the exception when tagData is set to null is:
java.awt.color.CMMException: Invalid profile: null
at sun.java2d.cmm.lcms.LCMS.getLcmsProfile(LCMS.java:56)
at sun.java2d.cmm.lcms.LCMS.getTagSize(LCMS.java:85)
at java.awt.color.ICC_Profile.getData(ICC_Profile.java:1372)
at java.awt.color.ICC_Profile.getData(ICC_Profile.java:1360)
at java.awt.color.ICC_Profile.getNumComponents(ICC_Profile.java:1470)
at sun.java2d.cmm.lcms.LCMSTransform.<init>(LCMSTransform.java:98)
at sun.java2d.cmm.lcms.LCMS.createTransform(LCMS.java:173)
at java.awt.color.ICC_ColorSpace.toRGB(ICC_ColorSpace.java:166)
at
org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB.init(PDDeviceRGB.java:69)
at
org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB.toRGB(PDDeviceRGB.java:103)
at org.apache.pdfbox.rendering.PageDrawer.getPaint(PageDrawer.java:237)
at
org.apache.pdfbox.rendering.PageDrawer.getNonStrokingPaint(PageDrawer.java:529)
at org.apache.pdfbox.rendering.PageDrawer.fillPath(PageDrawer.java:588)
at
org.apache.pdfbox.contentstream.operator.graphics.FillNonZeroRule.process(FillNonZeroRule.java:36)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:815)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:472)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:446)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.showForm(PDFStreamEngine.java:178)
at
org.apache.pdfbox.contentstream.operator.graphics.DrawObject.process(DrawObject.java:70)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:815)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:472)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:446)
at
org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:149)
at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:189)
at org.apache.pdfbox.rendering.PDFRenderer.renderPage(PDFRenderer.java:210)
at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:140)
at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:69)
at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:56)
at org.apache.pdfbox.rendering.TestRendering.render(TestRendering.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

This pointed out that the profile is null, in case of the ICC_profile class
this is the private field cmmProfile. That profile should be set by the
following 'guard' clause:
        if (ProfileDeferralMgr.deferring) {
            ProfileDeferralMgr.activateProfiles();
        }

The ICC_Profile is registered at the ProfileDeferralMgr for deferred
activation. But the ProfileDeferralMgr is _not_ thread safe.
ProfileDeferralMgr.deferring is a boolean which is set to false by the
ProfileDeferralMgr.activateProfiles() method. While
ProfileDeferralMgr.activateProfiles() is running,
ProfileDeferralMgr.deferring returns false and the caller will not be
blocked until the ProfileDeferralMgr.activateProfiles() is ready and _all_
registered ICC_Profile's are activated.

So.... All calls to Java CMM should be synchronized (not only
ColorSpace.toRGB). I have tested that, and it _seems_ to be working.
Another try is to force the profile deferral loading. I have done that via
a static part in PDDocument:
    static {
    PDDeviceRGB.INSTANCE.toRGB(new float[]{1,1,1,1});
    }
That _seems_ also to be working. I have run the test for ~50 times without
a problem.
We need the call in a central place like PDDocument because a static code
block on PDDeviceRGB will be executed when PDDeviceRGB is touched for the
first time and that could happen concurrently with other calls to
ICC_Profile.

Kind regards,
Cornelis Hoeflake

2016-02-06 0:20 GMT+01:00 John Hewson <jo...@jahewson.com>:

>
> > On 5 Feb 2016, at 10:32, Cornelis Hoeflake <c....@postex.com>
> wrote:
> >
> > 2016-02-05 18:42 GMT+01:00 John Hewson <john@jahewson.com <mailto:
> john@jahewson.com>>:
> >
> >>
> >>> On 4 Feb 2016, at 03:13, Cornelis Hoeflake <c....@postex.com>
> >> wrote:
> >>>
> >>> Hi,
> >>>
> >>> I get a NPE when building the latest 2.0 code on Jenkins. Is someone
> else
> >>> getting the same errors?
> >>> The exception is mostly when executing the 4PP-Highlighting.pdf, but I
> >> have
> >>> it also seen in 26101_Colors.ai.
> >>> We run Jenkins on Linux and the problem occurs with Oracle JDK 1.8_45
> and
> >>> Oracle JDK 1.8_72. On Windows I can reproduce it by using Oracle JDK
> >> 1.8_45
> >>> (no others tested).
> >>> The error occurs random, let us say 7 out of 10 times.
> >>
> >> I’ve not had the same error but we had a similar and longstanding
> problem
> >> with
> >> JDK 1.6, which was caused by a JDK bug in their ICC_Transform code, see
> >> see PDFBOX-2184 for more details.
> >>
> >
> > Do you also run on JDK 1.8?
>
> No, I’m on JDK 1.7 still.
>
> >> The exception occurs deep in Java and the NPE feels like a bug in the
> JVM.
> >>> Is the ColorSpace (at least ICC_Profile and ICC_ColorSpace) not thread
> >> safe
> >>> in Java (1.8)?
> >>
> >> The JDK bug encountered in PDFBOX-2184 was a thready safety bug, so this
> >> seems likely. Our workaround for that bug was to synchronize the
> >> initialisation of
> >> PDDeviceRGB, which is a singleton. But you’ve got two separate threads
> both
> >> calling PDDeviceRGB.init at the same time (and both hitting line 69)
> which
> >> should
> >> not be happening - so something seems to be going wrong?
> >>
> >
> > The two stacktraces are not executed concurrently. I attached the two to
> > show that there are two different stack traces.
>
> Ok, great, that makes sense now.
>
> > I have put a synchronized(ColorSpace.class) around all calls to
> > ColorSpace.toRGB from PDFBox ahd replaced the synchronisation in
> > PDDeviceRGB also with a synchronisation on ColorSpace.class, but that
> does
> > not solve the problem. Conclusion: not a concurrency issue?
>
> Looks that way.
>
> > I figured out that at when the NPE occurs, it goes wrong in this method:
> >
> >
> >
> > A CMMException occurs and null is returned which causes the NPE. But the
> > stacktrace of the CMMException is gone. I will have a look at that next
> > monday. Hopefully the CMMException is the same as exception of the second
> > stacktrace so that there is one problem in stead of two.
>
> Given our previous problems with Java’s CMM, some sort of initialisation
> bug
> related to either the Java or native portions of that code is looking like
> the prime
> culprit, so I think you’re on the right track. Hopefully we can work
> around it by
> calling the CMM in some specific order the first time we use it.
>
> — John
>
> > Kind regards,
> > Cornelis Hoeflake
>
>

Re: Random Exceptions in TestRendering

Posted by John Hewson <jo...@jahewson.com>.
> On 5 Feb 2016, at 10:32, Cornelis Hoeflake <c....@postex.com> wrote:
> 
> 2016-02-05 18:42 GMT+01:00 John Hewson <john@jahewson.com <ma...@jahewson.com>>:
> 
>> 
>>> On 4 Feb 2016, at 03:13, Cornelis Hoeflake <c....@postex.com>
>> wrote:
>>> 
>>> Hi,
>>> 
>>> I get a NPE when building the latest 2.0 code on Jenkins. Is someone else
>>> getting the same errors?
>>> The exception is mostly when executing the 4PP-Highlighting.pdf, but I
>> have
>>> it also seen in 26101_Colors.ai.
>>> We run Jenkins on Linux and the problem occurs with Oracle JDK 1.8_45 and
>>> Oracle JDK 1.8_72. On Windows I can reproduce it by using Oracle JDK
>> 1.8_45
>>> (no others tested).
>>> The error occurs random, let us say 7 out of 10 times.
>> 
>> I’ve not had the same error but we had a similar and longstanding problem
>> with
>> JDK 1.6, which was caused by a JDK bug in their ICC_Transform code, see
>> see PDFBOX-2184 for more details.
>> 
> 
> Do you also run on JDK 1.8?

No, I’m on JDK 1.7 still.

>> The exception occurs deep in Java and the NPE feels like a bug in the JVM.
>>> Is the ColorSpace (at least ICC_Profile and ICC_ColorSpace) not thread
>> safe
>>> in Java (1.8)?
>> 
>> The JDK bug encountered in PDFBOX-2184 was a thready safety bug, so this
>> seems likely. Our workaround for that bug was to synchronize the
>> initialisation of
>> PDDeviceRGB, which is a singleton. But you’ve got two separate threads both
>> calling PDDeviceRGB.init at the same time (and both hitting line 69) which
>> should
>> not be happening - so something seems to be going wrong?
>> 
> 
> The two stacktraces are not executed concurrently. I attached the two to
> show that there are two different stack traces.

Ok, great, that makes sense now.

> I have put a synchronized(ColorSpace.class) around all calls to
> ColorSpace.toRGB from PDFBox ahd replaced the synchronisation in
> PDDeviceRGB also with a synchronisation on ColorSpace.class, but that does
> not solve the problem. Conclusion: not a concurrency issue?

Looks that way.

> I figured out that at when the NPE occurs, it goes wrong in this method:
> 
>  1366 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1366 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1366>>
> 
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java# <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>>
> 
>    static byte[]
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java# <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>>getData(Profile
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/sun/java2d/cmm/Profile.java#Profile <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/sun/java2d/cmm/Profile.java#Profile>>
> p, int tagSignature) {
> 
> 1367 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1367 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1367>>
> 
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java# <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>>
> 
>    int tagSize;
> 
> 1368 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1368 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1368>>
> 
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java# <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>>
> 
>    byte[] tagData;
> 
> 1369 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1369 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1369>>
> 
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java# <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>>
> 
> 1370 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1370 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1370>>
> 
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java# <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>>
> 
>        try {
> 
> 1371 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1371 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1371>>
> 
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java# <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>>
> 
>            PCMM
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/sun/java2d/cmm/PCMM.java#PCMM <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/sun/java2d/cmm/PCMM.java#PCMM>>
> mdl = CMSManager.getModule
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/sun/java2d/cmm/CMSManager.java#CMSManager.getModule%28%29 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/sun/java2d/cmm/CMSManager.java#CMSManager.getModule%28%29>>();
> 
> 1372 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1372 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1372>>
> 
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java# <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>>
> 
> 1373 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1373 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1373>>
> 
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java# <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>>
> 
>            /* get the number of bytes needed for this tag */
> 
> 1374 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1374 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1374>>
> 
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java# <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>>
> 
>            tagSize = mdl.getTagSize
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/sun/java2d/cmm/PCMM.java#PCMM.getTagSize%28sun.java2d.cmm.Profile%2Cint%29 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/sun/java2d/cmm/PCMM.java#PCMM.getTagSize%28sun.java2d.cmm.Profile%2Cint%29>>(p,
> tagSignature);
> 
> 1375 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1375 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1375>>
> 
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java# <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>>
> 
> 1376 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1376 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1376>>
> 
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java# <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>>
> 
>            tagData = new byte[tagSize]; /* get an array for the tag */
> 
> 1377 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1377 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1377>>
> 
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java# <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>>
> 
> 1378 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1378 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1378>>
> 
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java# <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>>
> 
>            /* get the tag's data */
> 
> 1379 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1379 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1379>>
> 
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java# <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>>
> 
>            mdl.getTagData
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/sun/java2d/cmm/PCMM.java#PCMM.getTagData%28sun.java2d.cmm.Profile%2Cint%2Cbyte%5B%5D%29 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/sun/java2d/cmm/PCMM.java#PCMM.getTagData%28sun.java2d.cmm.Profile%2Cint%2Cbyte%5B%5D%29>>(p,
> tagSignature, tagData);
> 
> 1380 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1380 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1380>>
> 
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java# <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>>
> 
>        } catch(CMMException
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/CMMException.java#CMMException <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/CMMException.java#CMMException>>
> c) {
> 
> 1381 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1381 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1381>>
> 
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java# <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>>
> 
>            tagData = null;
> 
> 1382 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1382 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1382>>
> 
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java# <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>>
> 
>        }
> 
> 1383 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1383 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1383>>
> 
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java# <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>>
> 
> 1384 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1384 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1384>>
> 
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java# <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>>
> 
>        return tagData;
> 
> 1385 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1385 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1385>>
> 
> <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java# <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>>
> 
>    }
> 
> 
> A CMMException occurs and null is returned which causes the NPE. But the
> stacktrace of the CMMException is gone. I will have a look at that next
> monday. Hopefully the CMMException is the same as exception of the second
> stacktrace so that there is one problem in stead of two.

Given our previous problems with Java’s CMM, some sort of initialisation bug
related to either the Java or native portions of that code is looking like the prime
culprit, so I think you’re on the right track. Hopefully we can work around it by
calling the CMM in some specific order the first time we use it.

— John

> Kind regards,
> Cornelis Hoeflake


Re: Random Exceptions in TestRendering

Posted by Cornelis Hoeflake <c....@postex.com>.
2016-02-05 18:42 GMT+01:00 John Hewson <jo...@jahewson.com>:

>
> > On 4 Feb 2016, at 03:13, Cornelis Hoeflake <c....@postex.com>
> wrote:
> >
> > Hi,
> >
> > I get a NPE when building the latest 2.0 code on Jenkins. Is someone else
> > getting the same errors?
> > The exception is mostly when executing the 4PP-Highlighting.pdf, but I
> have
> > it also seen in 26101_Colors.ai.
> > We run Jenkins on Linux and the problem occurs with Oracle JDK 1.8_45 and
> > Oracle JDK 1.8_72. On Windows I can reproduce it by using Oracle JDK
> 1.8_45
> > (no others tested).
> > The error occurs random, let us say 7 out of 10 times.
>
> I’ve not had the same error but we had a similar and longstanding problem
> with
> JDK 1.6, which was caused by a JDK bug in their ICC_Transform code, see
> see PDFBOX-2184 for more details.
>

Do you also run on JDK 1.8?

> The exception occurs deep in Java and the NPE feels like a bug in the JVM.
> > Is the ColorSpace (at least ICC_Profile and ICC_ColorSpace) not thread
> safe
> > in Java (1.8)?
>
> The JDK bug encountered in PDFBOX-2184 was a thready safety bug, so this
> seems likely. Our workaround for that bug was to synchronize the
> initialisation of
> PDDeviceRGB, which is a singleton. But you’ve got two separate threads both
> calling PDDeviceRGB.init at the same time (and both hitting line 69) which
> should
> not be happening - so something seems to be going wrong?
>

The two stacktraces are not executed concurrently. I attached the two to
show that there are two different stacktraces.

I have put a synchronized(ColorSpace.class) around all calls to
ColorSpace.toRGB from PDFBox ahd replaced the synchronisation in
PDDeviceRGB also with a synchronisation on ColorSpace.class, but that does
not solve the problem. Conclusion: not a concurrency issue?

I figured out that at when the NPE occurs, it goes wrong in this method:

  1366 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1366>

<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>

    static byte[]
<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>getData(Profile
<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/sun/java2d/cmm/Profile.java#Profile>
p, int tagSignature) {

1367 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1367>

<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>

    int tagSize;

1368 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1368>

<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>

    byte[] tagData;

1369 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1369>

<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>

1370 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1370>

<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>

        try {

1371 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1371>

<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>

            PCMM
<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/sun/java2d/cmm/PCMM.java#PCMM>
mdl = CMSManager.getModule
<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/sun/java2d/cmm/CMSManager.java#CMSManager.getModule%28%29>();

1372 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1372>

<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>

1373 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1373>

<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>

            /* get the number of bytes needed for this tag */

1374 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1374>

<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>

            tagSize = mdl.getTagSize
<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/sun/java2d/cmm/PCMM.java#PCMM.getTagSize%28sun.java2d.cmm.Profile%2Cint%29>(p,
tagSignature);

1375 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1375>

<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>

1376 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1376>

<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>

            tagData = new byte[tagSize]; /* get an array for the tag */

1377 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1377>

<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>

1378 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1378>

<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>

            /* get the tag's data */

1379 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1379>

<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>

            mdl.getTagData
<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/sun/java2d/cmm/PCMM.java#PCMM.getTagData%28sun.java2d.cmm.Profile%2Cint%2Cbyte%5B%5D%29>(p,
tagSignature, tagData);

1380 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1380>

<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>

        } catch(CMMException
<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/CMMException.java#CMMException>
c) {

1381 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1381>

<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>

            tagData = null;

1382 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1382>

<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>

        }

1383 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1383>

<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>

1384 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1384>

<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>

        return tagData;

1385 <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#1385>

<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/awt/color/ICC_Profile.java#>

    }


A CMMException occurs and null is returned which causes the NPE. But the
stacktrace of the CMMException is gone. I will have a look at that next
monday. Hopefully the CMMException is the same as exception of the second
stacktrace so that there is one problem in stead of two.

Kind regards,
Cornelis Hoeflake

Re: Random Exceptions in TestRendering

Posted by John Hewson <jo...@jahewson.com>.
> On 4 Feb 2016, at 03:13, Cornelis Hoeflake <c....@postex.com> wrote:
> 
> Hi,
> 
> I get a NPE when building the latest 2.0 code on Jenkins. Is someone else
> getting the same errors?
> The exception is mostly when executing the 4PP-Highlighting.pdf, but I have
> it also seen in 26101_Colors.ai.
> We run Jenkins on Linux and the problem occurs with Oracle JDK 1.8_45 and
> Oracle JDK 1.8_72. On Windows I can reproduce it by using Oracle JDK 1.8_45
> (no others tested).
> The error occurs random, let us say 7 out of 10 times.

I’ve not had the same error but we had a similar and longstanding problem with
JDK 1.6, which was caused by a JDK bug in their ICC_Transform code, see
see PDFBOX-2184 for more details.

> TestPDFToImage should also fail (because it is using the same path for
> rendering), but that test is excluded. Why?

We use that for testing for local regressions on individual developer machines only.
It’s not run as part of a standard build because each JDK produces a slightly different
image rendering so we can’t compare them.

> The exception occurs deep in Java and the NPE feels like a bug in the JVM.
> Is the ColorSpace (at least ICC_Profile and ICC_ColorSpace) not thread safe
> in Java (1.8)?

The JDK bug encountered in PDFBOX-2184 was a thready safety bug, so this
seems likely. Our workaround for that bug was to synchronize the initialisation of
PDDeviceRGB, which is a singleton. But you’ve got two separate threads both
calling PDDeviceRGB.init at the same time (and both hitting line 69) which should
not be happening - so something seems to be going wrong?

— John

> See stacktraces below.
> 
> Kind regards,
> Cornelis Hoeflake
> 
> 
> Stacktrace 1:
> java.lang.NullPointerException: null
> at java.awt.color.ICC_Profile.intFromBigEndian(ICC_Profile.java:1782)
> at java.awt.color.ICC_Profile.getNumComponents(ICC_Profile.java:1474)
> at sun.java2d.cmm.lcms.LCMSTransform.<init>(LCMSTransform.java:98)
> at sun.java2d.cmm.lcms.LCMS.createTransform(LCMS.java:173)
> at java.awt.color.ICC_ColorSpace.toRGB(ICC_ColorSpace.java:166)
> at
> org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB.init(PDDeviceRGB.java:69)
> at
> org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB.toRGB(PDDeviceRGB.java:103)
> at org.apache.pdfbox.rendering.PageDrawer.getPaint(PageDrawer.java:237)
> at
> org.apache.pdfbox.rendering.PageDrawer.getNonStrokingPaint(PageDrawer.java:529)
> at org.apache.pdfbox.rendering.PageDrawer.fillPath(PageDrawer.java:588)
> at
> org.apache.pdfbox.contentstream.operator.graphics.FillNonZeroRule.process(FillNonZeroRule.java:36)
> at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:815)
> at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:472)
> at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:446)
> at
> org.apache.pdfbox.contentstream.PDFStreamEngine.showForm(PDFStreamEngine.java:178)
> at
> org.apache.pdfbox.contentstream.operator.graphics.DrawObject.process(DrawObject.java:70)
> at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:815)
> at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:472)
> at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:446)
> at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:149)
> at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:189)
> at org.apache.pdfbox.rendering.PDFRenderer.renderPage(PDFRenderer.java:210)
> at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:140)
> at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:69)
> at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:56)
> at org.apache.pdfbox.rendering.TestRendering.render(TestRendering.java:79)
> 
> Stacktrace 2:
> 
> java.awt.color.CMMException: Unknown profile ID
> at sun.java2d.cmm.lcms.LCMS.createTransform(LCMS.java:151)
> at sun.java2d.cmm.lcms.LCMSTransform.doTransform(LCMSTransform.java:155)
> at sun.java2d.cmm.lcms.LCMSTransform.colorConvert(LCMSTransform.java:629)
> at java.awt.color.ICC_ColorSpace.toRGB(ICC_ColorSpace.java:182)
> at
> org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB.init(PDDeviceRGB.java:69)
> at
> org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB.toRGB(PDDeviceRGB.java:103)
> at org.apache.pdfbox.rendering.PageDrawer.getPaint(PageDrawer.java:237)
> at
> org.apache.pdfbox.rendering.PageDrawer.getNonStrokingPaint(PageDrawer.java:529)
> at org.apache.pdfbox.rendering.PageDrawer.fillPath(PageDrawer.java:588)
> at
> org.apache.pdfbox.contentstream.operator.graphics.FillNonZeroRule.process(FillNonZeroRule.java:36)
> at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:815)
> at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:472)
> at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:446)
> at
> org.apache.pdfbox.contentstream.PDFStreamEngine.showForm(PDFStreamEngine.java:178)
> at
> org.apache.pdfbox.contentstream.operator.graphics.DrawObject.process(DrawObject.java:70)
> at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:815)
> at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:472)
> at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:446)
> at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:149)
> at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:189)
> at org.apache.pdfbox.rendering.PDFRenderer.renderPage(PDFRenderer.java:210)
> at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:140)
> at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:69)
> at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:56)
> at org.apache.pdfbox.rendering.TestRendering.render(TestRendering.java:79)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:497)
> at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
> at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
> at
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
> at org.junit.runners.Suite.runChild(Suite.java:128)
> at org.junit.runners.Suite.runChild(Suite.java:27)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
> at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
> at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> at java.lang.Thread.run(Thread.java:745)


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org