0

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

但有时(10 次中有 1 次)会导致 VM 崩溃


#
# 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,

“Start transformImage2”被打印,但“Improving quality of image”没有。所以我们知道它在这 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. 如何解决(当然:)?

4

3 回答 3

4

我建议检查随后的 JVM 版本

JRE version: 6.0_22-b22

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

于 2012-06-27T08:20:13.277 回答
1

好的,我觉得向您解释如何解决问题很愚蠢,但这就是我要做的:

  1. 停止在代码中查找错误,它不存在
  2. 找出你的程序在哪一行崩溃。开始禁用线路,看看它是否仍然崩溃。
  3. 升级涉及的组件。首先是ghostview库,然后是jdk,然后是操作系统。
  4. 开始切换组件。我一直在使用开源 jdk 时遇到问题,也许尝试切换到专有的 oracle 一个。然后尝试不同的操作系统。
于 2012-06-28T09:53:22.203 回答
0

我认为您需要设置堆大小

参考 http://viralpatel.net/blogs/jvm-java-increase-heap-size-setting-heap-size-jvm-heap/

于 2012-06-27T08:19:03.870 回答