使用javax.media.jai进行图像转换时JVM崩溃

时间:2012-06-27 08:17:35

标签: java java-ee jai jvm-crash

在我们的应用程序中,我们使用javax.media.JAI库来扩展和改进图像

但有时候(10次中有1次)会导致虚拟机崩溃


#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fdb6f49140b, pid=2153, tid=140580255180544
#
# JRE version: 6.0_22-b22
# Java VM: OpenJDK 64-Bit Server VM (20.0-b11 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea6 1.10.4
# Distribution: Fedora release 16 (Verne), package fedora-61.1.10.4.fc16-x86_64
# Problematic frame:
# C  [libgs.so+0x16940b]  s_DCT_set_defaults+0x8b
#
# An error report file with more information is saved as:
# /usr/share/tomcat/hs_err_pid2153.log
#
# If you would like to submit a bug report, please include
# instructions how to reproduce the bug and visit:
#   http://icedtea.classpath.org/bugzilla
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

向代码添加日志确实有助于确定确切的行


                DebugHelper.errorLog("Start transformImage2");
        List modImages = new ArrayList();
        PageImage page = new PageImage();

        // generate rendered image.
        RenderedOp im = JAI.create("fileload", image.getFile()
                .getAbsolutePath());

        // get the width and height of original image.
        float width = im.getWidth();
        float height = im.getHeight();

        // improve the quality of image.
        DebugHelper.errorLog("Improving quality of image");
        RenderingHints qualityHints = new RenderingHints(
                RenderingHints.KEY_RENDERING,
                RenderingHints.VALUE_RENDER_QUALITY);
        qualityHints.put(RenderingHints.KEY_ANTIALIASING,

“开始transformImage2”被打印,但“提高图像质量”却没有。所以我们知道这是3-4行。另外,从hs_err *文件中,它指向float width = im.getWidth();


Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  com.sun.imageio.plugins.jpeg.JPEGImageReader.initJPEGImageReader()J+0
j  com.sun.imageio.plugins.jpeg.JPEGImageReader.(Ljavax/imageio/spi/ImageReaderSpi;)V+174
j  com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi.createReaderInstance(Ljava/lang/Object;)Ljavax/imageio/ImageReader;+5
j  javax.imageio.spi.ImageReaderSpi.createReaderInstance()Ljavax/imageio/ImageReader;+2
j  javax.imageio.ImageIO$ImageReaderIterator.next()Ljavax/imageio/ImageReader;+16
j  javax.imageio.ImageIO$ImageReaderIterator.next()Ljava/lang/Object;+1
j  com.sun.image.codec.jpeg.JPEGCodec$ImageIOJPEGImageDecoder.(Ljava/io/InputStream;)V+26
j  com.sun.image.codec.jpeg.JPEGCodec$ImageIOJPEGImageDecoder.(Ljava/io/InputStream;Lcom/sun/image/codec/jpeg/JPEGCodec$1;)V+2
j  com.sun.image.codec.jpeg.JPEGCodec.createJPEGDecoder(Ljava/io/InputStream;)Lcom/sun/image/codec/jpeg/JPEGImageDecoder;+6
j  com.sun.media.jai.codecimpl.JPEGImage.(Ljava/io/InputStream;Lcom/sun/media/jai/codec/ImageDecodeParam;)V+35
j  com.sun.media.jai.codecimpl.JPEGImageDecoder.decodeAsRenderedImage(I)Ljava/awt/image/RenderedImage;+29
j  com.sun.media.jai.opimage.CodecRIFUtil.create(Ljava/lang/String;Ljava/awt/image/renderable/ParameterBlock;Ljava/awt/RenderingHints;)Ljava/awt/image/RenderedImage;+184
j  com.sun.media.jai.opimage.JPEGRIF.create(Ljava/awt/image/renderable/ParameterBlock;Ljava/awt/RenderingHints;)Ljava/awt/image/RenderedImage;+4
j  sun.reflect.GeneratedMethodAccessor740.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+48
J  sun.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
j  java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+161
j  javax.media.jai.FactoryCache.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+6
j  javax.media.jai.OperationRegistry.invokeFactory(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;+57
j  javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;+12
j  javax.media.jai.registry.RIFRegistry.create(Ljavax/media/jai/OperationRegistry;Ljava/lang/String;Ljava/awt/image/renderable/ParameterBlock;Ljava/awt/RenderingHints;)Ljava/awt/image/RenderedImage;+35
j  com.sun.media.jai.opimage.StreamRIF.create(Ljava/awt/image/renderable/ParameterBlock;Ljava/awt/RenderingHints;)Ljava/awt/image/RenderedImage;+191
j  sun.reflect.GeneratedMethodAccessor740.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+48
J  sun.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
j  java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+161
j  javax.media.jai.FactoryCache.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+6
j  javax.media.jai.OperationRegistry.invokeFactory(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;+57
j  javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;+12
j  javax.media.jai.registry.RIFRegistry.create(Ljavax/media/jai/OperationRegistry;Ljava/lang/String;Ljava/awt/image/renderable/ParameterBlock;Ljava/awt/RenderingHints;)Ljava/awt/image/RenderedImage;+35
j  com.sun.media.jai.opimage.FileLoadRIF.create(Ljava/awt/image/renderable/ParameterBlock;Ljava/awt/RenderingHints;)Ljava/awt/image/RenderedImage;+158
j  sun.reflect.GeneratedMethodAccessor740.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+48
J  sun.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
j  java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+161
j  javax.media.jai.FactoryCache.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+6
j  javax.media.jai.OperationRegistry.invokeFactory(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;+57
j  javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;+12
j  javax.media.jai.registry.RIFRegistry.create(Ljavax/media/jai/OperationRegistry;Ljava/lang/String;Ljava/awt/image/renderable/ParameterBlock;Ljava/awt/RenderingHints;)Ljava/awt/image/RenderedImage;+35
j  javax.media.jai.RenderedOp.createInstance(Z)Ljavax/media/jai/PlanarImage;+171
J  javax.media.jai.RenderedOp.createRendering()V
j  javax.media.jai.RenderedOp.getWidth()I+1
j  com.myapp.helpers.conversion.DocumentConverter.transformImage(Lcom/myapp/helpers/conversion/PageImage;Ljava/lang/String;Lcom/myapp/helpers/conversion/ImageSetting;)Ljava/util/List;+39
j  com.myapp.helpers.conversion.DocumentConverter.convertDocuments(Ljava/util/List;Ljava/lang/String;Lcom/myapp/helpers/conversion/ImageSetting;)Ljava/util/Map;+597
J  com.myapp.helpers.conversion.ConversionTask.run()V

所以我有几个问题

  1. 问题的确切原因是什么?

  2. 为什么错误不会一直发生,相同的图像有时会成功转换而在其他图像上会失败?

  3. 如何解决(当然:)?

3 个答案:

答案 0 :(得分:4)

我建议查看subsequent JVM releases

JRE version: 6.0_22-b22

相对较旧,并且有连续的JRE 6版本,以及(当然)Java 7.我怀疑更高版本是一种缓解此问题的简单方法。

答案 1 :(得分:1)

好吧,我觉得傻傻地解释你如何解决问题, 但这就是我要做的事情:

  1. 停止在代码中查找错误,它不在那里
  2. 找出你的程序崩溃的确切位置。 开始禁用行并查看它是否仍然崩溃。
  3. 升级涉及组件。 ghostview库首先是jdk,然后是os。
  4. 开始切换组件。我总是遇到开源jdk的麻烦, 也许尝试切换到专有的oracle一点。然后尝试不同的操作系统。

答案 2 :(得分:0)