Comment 9 for bug 913434

Revision history for this message
David White (cppege-david-9ei9ny) wrote :

I've found this issue happens intermitently on my setup:
Ubuntu 13.04 64-bit
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.13.04.2)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

I get an intermitent crash when decoding JPEGs, decoding in several threads.

Thread pool is created thus:
 ExecutorService threadpool = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()+1);

Image decode tasks added this:
 ImageScaler scaler = new ImageScaler(size);
 threadpool.submit(scaler);

ImageScaler class is:
 private class ImageScaler extends SwingWorker<ImageIcon, String> {
  private int size;

  public ImageScaler(int size) {
   this.size = size;
  }

  @Override
  public ImageIcon doInBackground() {
   LOGGER.log(Level.FINE,
     "Loading image: "+url);

   ImageReader ir;

   //create a new instance of imageReader
   synchronized(sync){
    Iterator<ImageReader> it = ImageIO.getImageReadersByMIMEType("image/jpeg");
    ir = it.next();
    if (ir == null) {
     LOGGER.log(Level.SEVERE,
       "No image reader found for JPEGs");
     System.exit(1);
    }
    ImageReaderSpi spi = ir.getOriginatingProvider();
    try {
     ir = spi.createReaderInstance();
    } catch (Exception e) {
     LOGGER.log(Level.SEVERE,
       "Could not create new JPEG reader instance", e);
     return null;
    }
   }

   //Load the image from the URL (could be local or HTTP)
   BufferedImage image;
   try {

[...]
    File cacheDir = new File (strCacheDir);
    cacheDir.mkdirs();
    URL u = new URL(url);
    FileCacheImageInputStream fcis = new FileCacheImageInputStream(
     u.openStream(), cacheDir);
    ir.setInput(fcis);
    image = ir.read(0);
    fcis.close();
   } catch (Exception e) {
    LOGGER.log(Level.WARNING,
      "Could not read image "+url, e);
    return null;
   } catch (OutOfMemoryError e) {
    LOGGER.log(Level.WARNING,
      "Out of memory reading image: "+url, e);
    return null;
   } finally {
    ir.dispose();
   }

   return new ImageIcon(resizeImage(image, size));
   }

  @Override
  protected void done() {
   if (isCancelled())
    return;
   ImageIcon icon = null;
   try {
    icon = get();
   } catch (Exception ignore) {}
   if (icon == null) {
    LOGGER.log(Level.WARNING,
      "Scaled image is null: "+url);
    return;
   }
   rendered = icon;
   renderedSize = size;
   mPcs.firePropertyChange(PNAME_RENDEREDICON, 0, 1);
  }

 }

The crash actually occurs in ICC_Profile code. I get intermitent colour issues with decoded JPEGs where the image is totally mid-green except for areas that are dark which tend to black. Is there an issue in the colour code for multi-threaded decode? I've done my best to create an image reader in a thread-safe way.

I've attached the crash log file.