title: Frequent JVM crash by SIGSEGV on cv::_OutputArray::create at libopencv_java342.so
body: <p>I am getting frequent JVM crash. Using opencv with Java Imgproc library. It gets called from findContours function of Imgproc library. </p>
  
  <blockquote>
    <p>Stack: [0x00007febe3875000,0x00007febe38f6000], 
    sp=0x00007febe38f3ea0,  free space=507k Native frames: (J=compiled
    Java code, j=interpreted, Vv=VM code, C=native code) C 
    [libopencv_java342.so+0x4a63f4]  cv::_OutputArray::create(int, int
    const*, int, int, bool, int) const+0x1b4</p>
    
    <p>Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) J
    103505  org.opencv.imgproc.Imgproc.findContours_1(JJJII)V (0 bytes) @
    0x00007fecec55770e [0x00007fecec5576c0+0x4e]</p>
  </blockquote>
  
  <p>Fatal error : </p>
  
  <blockquote>
    <p>A fatal error has been detected by the Java Runtime Environment:</p>
    
    <p>SIGSEGV (0xb) at pc=0x00007febd82453f4, pid=3462, tid=0x00007febe38f5700</p>
    
    <p>JRE version: Java(TM) SE Runtime Environment (8.0_141-b15) (build 1.8.0_141-b15)
     Java VM: Java HotSpot(TM) 64-Bit Server VM (25.141-b15 mixed mode linux-amd64 compressed oops)
     Problematic frame:
     C  [libopencv_java342.so+0x4a63f4]  cv::_OutputArray::create(int, int const*, int, int, bool, int) const+0x1b4</p>
    
    <p>Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again</p>
  </blockquote>
  
  <p>Additional details : </p>
  
  <p>Tried tuning JVM memory but didn't help. Any help would be appreciated.</p>
  
  <p>We are using <a href="https://docs.opencv.org/2.4/modules/imgproc/doc/imgproc.html" rel="nofollow noreferrer">Imgproc JAVA library</a> which usage libopencv_java342.so underneath. OS is Amazon Linux AMI VERSION="2018.03 (based on rhel fedora) </p>
  
  <p>Below function of opencv is getting called from the library. </p>
  
  <blockquote>
    <p>private static native void findContours(long image_nativeObj, long
    contours_mat_nativeObj, long hierarchy_nativeObj, int mode, int
    method);</p>
  </blockquote>