JNI EXCEPTION_ACCESS_VIOLATION (0xc0000005) msvcr100.dll+0x1ed7 in Windows only

0

We have a piece of JNI code that lets us link to a legacy C library. The Java app references the C dll/so to call the c methods which create a new Java object with loads of Integers, Longs and Strings and then passes back this object to the Java code. The Java code tries to print these values that it received back from C and randomly crashes at different points in the code. When we run this in Linux it runs with no problems but in Windows it intermittently crashes with:

# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x77e11ed7, pid=893220, 
   tid=887676
#
# JRE version: Java(TM) SE Runtime Environment (8.0_05-b13) (build 1.8.0_05- b13)
# Java VM: Java HotSpot(TM) Client VM (25.5-b02 mixed mode, sharing windows-x86 )
# Problematic frame:
# C  [msvcr100.dll+0x1ed7]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows

I would try to blame it on the god mode shortcut -> Fatal error crashing on latest version of Java on Windows 10 machine

But it only happens with some bits of code and not the others... so it's definitely some thing up how the jni bit was done C side.

java
c
java-native-interface
access-violation
asked on Stack Overflow Oct 29, 2018 by Javadee • edited Oct 30, 2018 by halfer

2 Answers

0

Looks like some kind of null pointer problem since the access occurred close to 0 (0xc0000005). Since it is not exactly null there might be some wrongly coded pointer arithmetic in your C code.

answered on Stack Overflow Oct 29, 2018 by TomWolk
0

After a lot of debugging the issue was resolved by changing couple of java inner classes to static. These inner classes were being referenced from the C code.

public class MyClass{
   // public class MyInnerClass{}
   // was changed to 
   public static class MyInnerClass{}
}

Obviously all the jni references from C were also changed to reflect that. Still not sure why but the issue is resolved now.

answered on Stack Overflow Apr 17, 2019 by Javadee

User contributions licensed under CC BY-SA 3.0