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

JVM crashes when loading a LCMSProfile.

XMLWordPrintable

    • x86_64
    • linux_suse_slec

      ADDITIONAL SYSTEM INFORMATION :
      OpenSuse 15.6, OpenJDK Runtime Environment (build 21.0.7+6-suse-150600.3.12.1-x8664)

      A DESCRIPTION OF THE PROBLEM :
      So far I could only reproduce it on a single PNG file when loading it into the pdf file using PDFBox library.
      It only happens when multiple threads are loading that PNG file into multiple pdf files.
      The reason I'm raising a ticket here and not PDFBox, is that I can reproduce this with pure JDK code.

      I cannot find information about thread safety of the ICC_Profile class in the API doc, but I assume it should be basing on the code (syncronized blocks in cmmProfile() method, lock.readLock() in LCMSProfile.getProfileData(), etc.).

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      I just run the included source code.


      ACTUAL -
      Crash and core dump.

      ---------- BEGIN SOURCE ----------
      import java.awt.color.ColorSpace;
      import java.awt.color.ICC_Profile;

      public class App {

          public static void main(String[] args) throws Exception {
              for (int i = 0; i < 100; i++) {
                  System.out.println(i + 1);
                  test();
              }
          }

          private static void test() throws InterruptedException {
              Thread[] threads = new Thread[10];
              for (int i = 0; i < threads.length; i++) {
                  threads[i] = new Thread(App::loadData, "thread-" + i);
              }
              for (Thread thread : threads) {
                  thread.start();
              }
              for (Thread thread : threads) {
                  thread.join();
              }
          }

          // works when synchronized
      // private synchronized static void loadData() {
          private static void loadData() {
              ICC_Profile.getInstance(ColorSpace.CS_sRGB).getData();
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      As in the provided source code - when I synchronize the `getData()` call, it works.

      FREQUENCY : always


            abaya Anass Baya
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: