JVM crashes reading Image

364 views
Skip to first unread message

Kevin M

unread,
Apr 16, 2021, 8:08:16 AM4/16/21
to dcm4che

Hi,

I have encountered an issue where occasionally, the JVM crashes when trying to read a JPG image. This does not occur all the time when uploading the same image.
I am running a Java web application on Tomcat, which allows users to upload images which we save.

My Java code is reading the image as follows

myImagesInputStream = new ByteArrayInputStream(originalFileInBytes);
BufferedImage bufferedImage = ImageIO.read( myImagesInputStream );

On occasion, the JVM crashes and I get the following error logged, which indicates a problem with libclib_jiio.so+0x74dfc]  jpeg_read_markers+0xf8c

I am using the linux-x86_64 version of the libclib_jiio.so library in dcm4che 5.22.6.

Has anyone encountered this issue before?

Thanks,

Kevin.

15-Apr-2021 17:19:32.416 INFO [http-nio-8080-exec-20] org.opencv.osgi.OpenCVNativeLoader.init Successfully loaded OpenCV native library.
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f7cc2986dfc, pid=12977, tid=0x00007f7cc4d41700
#
# JRE version: OpenJDK Runtime Environment (8.0_265-b01) (build 1.8.0_265-b01)
# Java VM: OpenJDK 64-Bit Server VM (25.265-b01 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [libclib_jiio.so+0x74dfc]  jpeg_read_markers+0xf8c

#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /tmp/hs_err_pid12977.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#


The hs_err_pid.log file created details the following :

Stack: [0x00007f7cc4c41000,0x00007f7cc4d42000],  sp=0x00007f7cc4d3c040,  free space=1004k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libclib_jiio.so+0x74dfc]  jpeg_read_markers+0xf8c

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  com.sun.medialib.codec.jpeg.Decoder.njpeg_decode(J[I)V+0
j  com.sun.medialib.codec.jpeg.Decoder.decode(Lcom/sun/medialib/codec/jiio/mediaLibImage;)Lcom/sun/medialib/codec/jiio/mediaLibImage;+20
j  com.sun.media.imageioimpl.plugins.jpeg.CLibJPEGImageReader.decode(Ljava/io/InputStream;)Lcom/sun/medialib/codec/jiio/mediaLibImage;+44
j  com.sun.media.imageioimpl.plugins.clib.CLibImageReader.getImage(I)Lcom/sun/medialib/codec/jiio/mediaLibImage;+82
j  com.sun.media.imageioimpl.plugins.clib.CLibImageReader.read(ILjavax/imageio/ImageReadParam;)Ljava/awt/image/BufferedImage;+37
j  javax.imageio.ImageIO.read(Ljavax/imageio/stream/ImageInputStream;)Ljava/awt/image/BufferedImage;+55

j  javax.imageio.ImageIO.read(Ljava/io/InputStream;)Ljava/awt/image/BufferedImage;+34
j  com.my.service.theservice.MyServiceImpl.createImage(Lorg/springframework/web/multipart/MultipartFile;Lmy/service/jdbc/dao/model/abc;JJILjava/lang/String;Ljava/lang/String;Ljava/lang/String;J)J+1828
v  ~StubRoutines::call_stub

Santiago Gala

unread,
Apr 16, 2021, 11:17:21 AM4/16/21
to dcm...@googlegroups.com
You are using jdk version 25.265-b01 , which is not the last.

If I check (in my ubuntu) apt changelog openjdk-8 I find that the las
version is 8u282-b08 and that
openjdk-8 version 8u272-b10 contains, amongst other changes, this one:
- JDK-8253019: Enhanced JPEG decoding.

So I would look for the issue JDK-8253019 and check if upgrading the
JDK fixes the issue...

Regards
Santiago
> --
> You received this message because you are subscribed to the Google Groups "dcm4che" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to dcm4che+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/dcm4che/7fefda83-5aa4-48a4-97a6-5eaf051b550en%40googlegroups.com.

Kevin M

unread,
Apr 19, 2021, 3:45:48 AM4/19/21
to dcm4che
Many thanks Santiago.
I will give this a try.

Kevin

Kevin M

unread,
Apr 19, 2021, 4:32:34 AM4/19/21
to dcm4che
I checked one of our environment which is already on 8u282 -b08 and our issue occurs there too.

davidm...@gmail.com

unread,
Apr 22, 2021, 5:31:06 PM4/22/21
to dcm4che
I don't have any insight into the intermittent crashes but have a question about where you package the native libs in the first place.  Do you put them in the jdk, something like jre/lib/ext? Do you put them in tomcat's shared lib space, something like /var/lib/tomcat9/lib? Or do you put them in the webapp's library, something like WEB_INF/lib/linux-x86_64/?  I can't figure out where to put them so they are loaded at all.

Kevin McGonagle

unread,
Apr 23, 2021, 5:26:03 AM4/23/21
to dcm...@googlegroups.com
Hi David,

I added the native libraries to a separate directory (ie. /my/dir/lib/linux-x86_64)

I then added the libraries to my Web Server path via the java.library.path property (ie -Djava.library.path=/my/dir/lib/linux-x86_64)

Kevin,

You received this message because you are subscribed to a topic in the Google Groups "dcm4che" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dcm4che/lBMdLmZmq6A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dcm4che+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dcm4che/cae6b416-9cb5-4561-a14c-95c0da1eb226n%40googlegroups.com.

Tatsunidas

unread,
Apr 23, 2021, 5:51:37 AM4/23/21
to dcm...@googlegroups.com
Hello, Kevin

If you do not have time, you can decompress using the dcm2dcm.
I hope this helps.

Tatsuaki

2021年4月23日(金) 18:26 'Kevin McGonagle' via dcm4che <dcm...@googlegroups.com>:


--
==========================================
Tatsuaki KOBAYASHI
TEL:080-1274-6433
Good Luck
==========================================

davidm...@gmail.com

unread,
Apr 23, 2021, 9:36:00 AM4/23/21
to dcm4che
Thanks, Kevin.  I think the point I was missing is that native libraries can't be put in directories and picked up like normal jars. They need to be put explicitly on the classpath.  I hope to be pumping a variety of data through my app shortly and will be on the lookout for the behavior you are seeing.

Dave.

davidm...@gmail.com

unread,
Apr 27, 2021, 1:57:52 PM4/27/21
to dcm4che
Hi Kevin,
I posted a new message to the group here: https://groups.google.com/g/dcm4che/c/EBlbgikgLjY. Do you see any thing different between our environments that might explain why this isn't working for me?

Thanks,
Dave

Reply all
Reply to author
Forward
0 new messages