pdfbox-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tilman Hausherr (Jira)" <j...@apache.org>
Subject [jira] [Commented] (PDFBOX-3641) ICC_ColorSpace usage is not thread safe
Date Sat, 26 Oct 2019 12:03:00 GMT

    [ https://issues.apache.org/jira/browse/PDFBOX-3641?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16960331#comment-16960331
] 

Tilman Hausherr commented on PDFBOX-3641:
-----------------------------------------

The jdk issue is said to have been fixed for jdk14, see linked jdk issue. I'll test when the
next ea comes out.

> ICC_ColorSpace usage is not thread safe
> ---------------------------------------
>
>                 Key: PDFBOX-3641
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3641
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Rendering
>    Affects Versions: 2.0.4
>            Reporter: Mike Kaplinskiy
>            Assignee: Tilman Hausherr
>            Priority: Major
>             Fix For: 2.0.5, 3.0.0 PDFBox
>
>         Attachments: PDFBOX-3641-731495-p33-veryslow.pdf, PDFBOX-3641.icc
>
>
> Unfortunately {{ICC_ColorSpace}} is not thread safe. Even creating {{Color}} instances
and passing an {{ICC_ColorSpace}} can't be considered thread safe. All color conversion calls
lazy initialize a value without a memory barrier: https://github.com/openjdk-mirror/jdk/blob/jdk8u/jdk8u/master/src/share/classes/java/awt/color/ICC_ColorSpace.java#L172
. This seems like a bug in Java, but PDFBox triggers it :(
> PDFBox seems to attempt to initialize colorspaces/colors in a thread-safe way around
https://github.com/apache/pdfbox/blob/f419d203ebebc4deb83ba71ef0a0e6bb1ff22c5a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java#L146
, but calls to {{toRGB}}/{{fromRGB}} aren't synchronized. I *think* calling all 4 (to/from)(CIEXYZ/RGB)
in a locked block *should* initialize the instances enough to be thread safe.
> The symptoms of this problem look like this (exception formatting due to clojure):
> {code}
>                      org.apache.pdfbox.rendering.PDFRenderer.renderImageWithDPI     
         PDFRenderer.java:   94
>                             org.apache.pdfbox.rendering.PDFRenderer.renderImage     
         PDFRenderer.java:  145
>                                 org.apache.pdfbox.rendering.PageDrawer.drawPage     
          PageDrawer.java:  189
>                     org.apache.pdfbox.contentstream.PDFStreamEngine.processPage     
     PDFStreamEngine.java:  149
>                   org.apache.pdfbox.contentstream.PDFStreamEngine.processStream     
     PDFStreamEngine.java:  446
>          org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators     
     PDFStreamEngine.java:  472
>                 org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator     
     PDFStreamEngine.java:  815
> org.apache.pdfbox.contentstream.operator.color.SetNonStrokingColorSpace.process  SetNonStrokingColorSpace.java:
  41
>                             org.apache.pdfbox.pdmodel.PDResources.getColorSpace     
         PDResources.java:  166
>                             org.apache.pdfbox.pdmodel.PDResources.getColorSpace     
         PDResources.java:  196
>                    org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.create     
        PDColorSpace.java:  182
>                      org.apache.pdfbox.pdmodel.graphics.color.PDICCBased.<init>
               PDICCBased.java:   89
>              org.apache.pdfbox.pdmodel.graphics.color.PDICCBased.loadICCProfile     
          PDICCBased.java:  145
>                                                           java.awt.Color.<init>
                    Color.java:  542
>                                             java.awt.color.ICC_ColorSpace.toRGB     
      ICC_ColorSpace.java:  179
> java.lang.NullPointerException:
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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


Mime
View raw message