Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8041429

Parallel read of Different JPG image files (by 2 thread) fails in Java 8

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.8.0_05"
      Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]


      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Processor Intel(R) Core(TM) i7 CPU 930 @ 2.80GHz, 2801 Mhz, 4 Core(s), 8 Logical Processor(s)

      Installed Physical Memory (RAM) 8.00 GB


      A DESCRIPTION OF THE PROBLEM :
      Two threads reading jpg images with ImageIO.read(File) either fail or read corrupted images for certain jpg files, when using java 8.

      * When java 7 or java 6 is used (not java 8) with 2 or 4 threads images are read fine.
      * When one thread is used to read images with java 8, images are read fine.
      * FYI, jpg images are created with Adobe Photoshop CS5.

      * The problem happens quite consistently but not always in java 8. Also, if one image is read first, and then more images are read in parallel, then images are being read fine.

      REGRESSION. Last worked in version 7u55

      ADDITIONAL REGRESSION INFORMATION:
      Works fine for:
      java version "1.7.0_55"
      Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)

      and works fine for this;

      java version "1.6.0_30"
      Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
      Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Test images which consistently fail can be found at
      https://www.dropbox.com/sh/g0mc2jpgk8pozqu/4z8WAlUd_B

      Simple java program that reproduces the problem can also be found at the same location.

      Description of the simple test program:
      * The program reads different jpg images in parallel
      * does some simple processing of each
      * terminates.

      The simple processing to assure that the images are read correctly involves calculating sum of rgb values for a specific set of pixels.

      To reproduce problem, run provided reproduceBug.bat with different java versions and different number of threads.

      For example, (run 2 threads, expect sum of pixels' rgbs to be -10901528596)

      reproduceBug 2 -10901528596

      would succeed on java 7 and 6

      But, on java 8

      if images read by one thread only:

      reproduceBug.bat 1 -10906004836

      consistent sum is produced

      But if 2 or more threads are used

      reproduceBug.bat 2

      results are inconsistent, or exception is thrown:

      Caused by: java.awt.color.CMMException: LCMS error 13: Couldn't link the profiles
      at sun.java2d.cmm.lcms.LCMS.createNativeTransform(Native Method)
      at sun.java2d.cmm.lcms.LCMS.createTransform(LCMS.java:156)
      at sun.java2d.cmm.lcms.LCMSTransform.doTransform(LCMSTransform.java:155)
      at sun.java2d.cmm.lcms.LCMSTransform.colorConvert(LCMSTransform.java:467)
      at java.awt.image.ColorConvertOp.filter(ColorConvertOp.java:571)
      at com.sun.imageio.plugins.jpeg.JPEGImageReader.acceptPixels(JPEGImageReader.java:1268)
      at com.sun.imageio.plugins.jpeg.JPEGImageReader.readImage(Native Method)
      at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:1236)
      at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:1039)
      at javax.imageio.ImageIO.read(ImageIO.java:1448)
      at javax.imageio.ImageIO.read(ImageIO.java:1308)
      at reproduce.bug.ImageReader.call(ImageReader.java:18)
      at reproduce.bug.ImageReader.call(ImageReader.java:1)
      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)








      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Java 6/7 reads different jpg images consistently, regardless of how many threads are used.

      When Java 8 read images, it produces inconsistent results (or exception is thrown) if 2 or more threads are used to read Different jpg image files.

      Using java 8 and 1 thread produces consistent image reads, (although results are somewhat different from java 6/7).

      Please see above for details.
      ACTUAL -
      Please see above for details.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Please see above for details.

      REPRODUCIBILITY :
      This bug can be reproduced often.

      ---------- BEGIN SOURCE ----------
      Source code can be found at:

      https://www.dropbox.com/sh/g0mc2jpgk8pozqu/4z8WAlUd_B
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      1) Avoid using java 8.
      2) Force image reading to one thread, even when images are from different files.

            prr Philip Race
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: