This is a multi-threading problem with LCMS version 2.5. It was claimed to have 
been fixed with LCMS v2.6, but many OS are still running the older packages.  I 
have code that parses PDF files. It is running in a production environment on 
random PDF files and with lots of threads. I was able to stop the error (~2 
years ago) by adding "syncronized" keyword around the following block of java 
code:
   ICC_Profile profile = ICC_Profile.getInstance(byte[]);
   ICC_ColorSpace colorSpace = new ICC_ColorSpace(profile);
   int numComponents = 3;  // From PDF dictionary, typically '3' (RGB).
   float[] components = new float[numComponents];

   // Test that ICC_Profile can be parsed
   // Generates an exception on malformed byte[]
   // Crashes JVM sporadically if not forced inline by 'syncronized'
   new java.awt.Color(colorSpace,components,1f);


If it helps, here's my java method (won't compile as it is missing methods):
        public static synchronized PDFColorSpace getICCColorSpace(PDFToken 
dict) throws IOException {
                PDFColorSpace cs=null;
                PDFToken nToken = dict.getDictionaryItem(N);
                int numComponents = (nToken==null) ? 1 : nToken.getInteger();

                try {                   
                        
                        ICC_Profile profile = 
ICC_Profile.getInstance(dict.getStream().toString8().getBytes());
                        
                        // This does not prevent JVM Crash with BELL.SW
                        // if (profile.getNumComponents() == numComponents) ...
                        
                        ICC_ColorSpace colorSpace = new ICC_ColorSpace(profile);
                        cs = new NativeColorSpace(TypeICC,colorSpace);
                                                        
                        // Test if ICC_Profile is OK. Will throw Exception (or 
even crash the JVM)
                        //   eg: Cik#99001898, 
http://www.siemens.com/investor/pool/de/investor_relations/events/hauptversammlung/2012/dividendenbekanntmachung.pdf,
 pg0
                        //   eg: JVM Crash, Cik#99002137, BELL.SW
                        float[] components = new float[numComponents];
                        new java.awt.Color(colorSpace,components,1f);
                        
                } catch (Exception e) {
                        cs=null;
                }
        return cs;
      }

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/913434

Title:
  ImageIO crashes (core dumped) while reading many image files

To manage notifications about this bug go to:
https://bugs.launchpad.net/openjdk/+bug/913434/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to