bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.57k stars 1.58k forks source link

JVM Crash with Mat.release() #1114

Closed DBrown2019 closed 5 years ago

DBrown2019 commented 5 years ago

So, I'm currently making a project that involves scanning a PDF into java Images, then converting it to Mat, and Finally to PIX. However, I've recently been plagued by JVM crashes in execution, with the problematic frame being cv::Mat::release()+0xc7. This is my first time using external libraries with Java, so I'm not sure what exactly this all means.

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f8fec184e4b, pid=17590, tid=0x00007f9057dfd700
#
# JRE version: OpenJDK Runtime Environment (8.0_192-b26) (build 1.8.0_192-b26)
# Java VM: OpenJDK 64-Bit Server VM (25.192-b26 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [libopencv_java343.so+0x345e4b]  cv::Mat::release()+0xc7
#
# Core dump written. Default location: /home/alvis/Projects/LocalHistoryEventsScanner/core or core.17590
#
# An error report file with more information is saved as:
# /home/alvis/Projects/LocalHistoryEventsScanner/hs_err_pid17590.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.
#
Disconnected from the target VM, address: '127.0.0.1:39585', transport: 'socket'

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

Is this issue on my end, or something with JavaCV?

The Core Dump is here: Core Dump

saudet commented 5 years ago

There's been a few things fixed around that recently. Could you try with version 1.4.4-SNAPSHOT?

DBrown2019 commented 5 years ago

Actually, I think I may have found a fix. I was using

private Mat BufferedImage2Mat(BufferedImage image){
        opencv_core.Mat mat2 = openCVFrameConverter.convert(java2DFrameConverter.convert(image));
        return new Mat(mat2.address());
}

In order to convert between the two types of Mats, and I haven't had the issue again since I discovered convertToOrgOpenCvCoreMat in OpenCvFrameConverter. I'm having another issue now with how the images convert, which I'll be opening an issue for once I have the data I need, but at least it isn't crashing.