In depth analysis of JVM error reporting problems based on jni invocation

  • 2020-04-01 01:58:25
  • OfStack

Execute the following jni call:

package jni;
public class JNITransObject {
 public native TestJNI[] ObjectMethod(String text);

 static {
  System.loadLibrary("JNITransObject");
 }

 public static void main(String args[]) {
  JNITransObject jniTransObject = new JNITransObject();

  TestJNI[] testJNIs = jniTransObject.ObjectMethod("jni trans object");

  for (int i = 0; i < testJNIs.length; i++) {
   System.out.println(testJNIs[i].getTopic());
  }
 }
}

When, report the following error:
#
# A fatal error has been detected by the Java Runtime Environment:
#
#   EXCEPTION_ACCESS_VIOLATION = 0 (0 xc0000005) at PC x6d91c1db, pid = 3544, tid = 5408
#
# JRE version: 6.0 _21 - b06
Java HotSpot(TM) Client VM (17.0-b16 mixed mode, sharing windows-x86)
# Problematic frame:
# V  [JVM. DLL + 0 x11c1db]
#
If you would like to submit a bug report, please visit:
#     http://java.sun.com/webapps/bugreport/crash.jsp
#
-- -- -- -- -- -- -- -- -- -- -- -- -- -- --   T H R E A D  ---------------
The Current thread (0 x01aa6400) :   JavaThread "main" [_thread_in_vm, id=5408, stack(0x00160000,0x001b0000)]
Siginfo: ExceptionCode=0xc0000005, reading address 0x00000009
Registers:
EAX = 0 x00000005 EBX = 0 x00002000, ECX = 0 x00000006, EDX x23b47f28 = 0
ESP = 0 x001afa9c, EBP = 0 x001afaa8, ESI = 0 x01aa6400, EDI x01aa6400 = 0
The EIP = 0 x6d91c1db x00010202 EFLAGS = 0
The Top of the Stack: (sp = 0 x001afa9c)
0 x001afa9c:     01 aa6400 37 b19738 d3b8 afaf8 001 3851
0 x001afaac:     01 b89f47 01 aa6518 afb00 afb18 001 001
0 x001afabc:     23 b23bc0 afb10 00000000 00002000 001
0 x001afacc:     6 d8f1751 aa6400 00000006 001 afad8 01
0 x001afadc:     Afb18 ca08 00000000 3851 00000000 001
0 x001afaec:     001 3851 00000000 001 afb08 d3b8 afb3c
0 x001afafc:     01 b82da1 b317c8 01 b88269 38, 00002000
0 x001afb0c:     23 b47f28 b23bc0 23 00000005 00000000
Instructions: = 0 x6d91c1db (PC)
0 x6d91c1cb:     74 5f 8b 55 18 85 d2 74 58 8b 5d 20 8b 12 8b 00
0 x6d91c1db:     8b 48 04 8b 79 08 56 53 8b 5d 1c 53 52 8b 55 14
X00160000 Stack: [0, 0 x001b0000],   Sp = 0 x001afa9c,   Free space = 13 e001af45ck
Native frames: (J=compiled Java code, J= interpretation, Vv=VM code, C= Native code)
V  [JVM. DLL + 0 x11c1db]
J  Java. Lang. System. Arraycopy (Ljava/lang/Object; ILjava/lang/Object; II) V + 0
J  Java. Lang. String. GetChars (II (CI) V + 62
J  Java. IO. BufferedWriter. Write (Ljava/lang/String; II) V + 63
J  Java. IO. Writer. Write (Ljava/lang/String;) V + 7
J  Java. IO. PrintStream. Write (Ljava/lang/String;) V + 13
J  Java. IO. PrintStream. Print (Ljava/lang/String;) V + 9
J  Java. IO. PrintStream. Println (Ljava/lang/String;) V + 6
J  Jni. JNITransObject. Main ([Ljava/lang/String;) V + 29
V  ~ StubRoutines: : call_stub
V  [JVM. DLL + 0 xf3abc]
V  [JVM. DLL + 0 x1865b1]
V  [JVM. DLL + 0 xf3b3d]
V  [JVM. DLL + 0 xfd385]
V  [JVM. DLL + 0 x104fdd]
C  [javaw. Exe + 0 x2155]
C  [javaw. Exe + 0 x8614]
C  [kernel32. DLL + 0 x4ed6c]
C  [NTDLL. DLL + 0 x637f5]
C  [NTDLL. DLL + 0 x637c8]
Java frames: (J=compiled Java code, J= interpretation, Vv=VM code)
J  Java. Lang. System. Arraycopy (Ljava/lang/Object; ILjava/lang/Object; II) V + 0
J  Java. Lang. String. GetChars (II (CI) V + 62
J  Java. IO. BufferedWriter. Write (Ljava/lang/String; II) V + 63
J  Java. IO. Writer. Write (Ljava/lang/String;) V + 7
J  Java. IO. PrintStream. Write (Ljava/lang/String;) V + 13
J  Java. IO. PrintStream. Print (Ljava/lang/String;) V + 9
J  Java. IO. PrintStream. Println (Ljava/lang/String;) V + 6
J  Jni. JNITransObject. Main ([Ljava/lang/String;) V + 29
V  ~ StubRoutines: : call_stub
-- -- -- -- -- -- -- -- -- -- -- -- -- -- --   P R O C E S S  ---------------
Java Threads: (= > The current thread)
  0x01b2e800 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=7580, stack(0x03e10000,0x03e60000)]
  0x01b21800 JavaThread "CompilerThread0" daemon [_thread_blocked, id=6392, stack(0x03dc0000,0x03e10000)]
  0x01b19800 JavaThread "Attach Listener" daemon [_thread_blocked, id=6364, stack(0x03d70000,0x03dc0000)]
  0x01b16c00 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=6360, stack(0x03d20000,0x03d70000)]
  0x01acd000 JavaThread "Finalizer" daemon [_thread_blocked, id=6348, stack(0x03cd0000,0x03d20000)]
  0x01acb800 JavaThread "Reference Handler" daemon [_thread_blocked, id=6316, stack(0x03c80000,0x03cd0000)]
= > 0x01aa6400 JavaThread "main" [_thread_in_vm, id=5408, stack(0x00160000,0x001b0000)]
Other Threads:
  0x01aca400 VMThread [stack: 0x03c30000,0x03c80000] [id=6320]
  0x01b2f400 WatcherThread [stack: 0x03e60000,0x03eb0000] [id=4824]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
Heap
  Def new generation    Total 4928K, used 1479K [0x23b10000, 0x24060000, 0x29060000)
  Eden space 4416 k,   33% used [0x23b10000, 0x23c81ef8, 0x23f60000)
  From space, 512 k,     0% used [0x23f60000, 0x23f60000, 0x23fe0000)
  To    Space 512 k,     0% used [0x23fe0000, 0x23fe0000, 0x24060000)
  Tenured generation    Total 10944K, used 0K [0x29060000, 0x29b10000, 0x33b10000)
    The space of 10944 k,     0% used [0x29060000, 0x29060000, 0x29060200, 0x29b10000)
  Compacting perm gen  Total 12288K, used 368K [0x33b10000, 0x34710000, 0x37b10000)
    The space of 12288 k,     2% used [0x33b10000, 0x33b6c1d0, 0x33b6c200, 0x34710000)
      Ro space 10240 k,   51% used [0x37b10000, 0x3803b700, 0x3803b800, 0x38510000)
      Rw space 12288 k,   54% used [0x38510000, 0x38ba76c0, 0x38ba7800, 0x39110000)
The Dynamic libraries:
0x00400000-0x00424000 C:\Program Files\Java\jre6\bin\javaw.exe
0 x77720000 x7785c000 0 C: \ Windows \ SYSTEM32 \ NTDLL DLL
0 x75b10000 x75be4000 0 C: \ Windows \ system32 \ kernel32 DLL
0 x75830000 x7587a000 0 C: \ Windows \ system32 \ KERNELBASE DLL
0 x774c0000 x77560000 0 C: \ Windows \ system32 \ ADVAPI32 DLL
0 x77340000 x773ec000 0 C: \ Windows \ system32 \ MSVCRT DLL
0 x77870000 x77889000 0 C: \ Windows \ SYSTEM32 \ sechost DLL
0 x760b0000 x76151000 0 C: \ Windows \ system32 \ RPCRT4 DLL
0 x75ec0000 x75f89000 0 C: \ Windows \ system32 \ USER32 DLL
0 x76010000 x7605e000 0 C: \ Windows \ system32 \ GDI32 DLL
0 x75b00000 x75b0a000 0 C: \ Windows \ system32 \ LPK DLL
0 x75a50000 x75aed000 0 C: \ Windows \ system32 \ USP10 DLL
0 x77030000 x7704f000 0 C: \ Windows \ system32 \ IMM32 DLL
0 x76db0000 x76e7c000 0 C: \ Windows \ system32 \ MSCTF DLL
0x7c340000-0x7c396000 C:\Program Files\Java\jre6\bin\msvcr71.dll
0x6d800000-0x6daa7000 C:\Program Files\Java\jre6\bin\client\jvm.dll
0 x755f0000 x75622000 0 C: \ Windows \ system32 \ WINMM DLL
0 x754a0000 x754ec000 0 C: \ Windows \ system32 \ apphelp DLL
0x6d7b0000-0x6d7bc000 C:\Program Files\Java\jre6\bin\ verification. DLL
0x6d330000-0x6d34f000 C:\Program Files\Java\jre6\bin\java.dll
0x6d290000-0x6d298000 C:\Program Files\Java\jre6\bin\hpi.dll
0 x76e80000 x76e85000 0 C: \ Windows \ system32 \ PSAPI DLL
0x6d7f0000-0x6d7ff000 C:\Program Files\Java\jre6\bin\zip
0 x10000000-0 x10039000 E: \ workspace \ Zhy \ JNITransObject DLL
The VM Arguments:
Jvm_args: - Dfile. Encoding = GBK
Java_command: jni. JNITransObject
The Launcher Type: SUN_STANDARD
Environment Variables:
JAVA_HOME = C: \ Program Files \ Java \ jdk1.6.0 _21
The CLASSPATH =. C: \ Program Files \ Java \ jdk1.6.0 _21 \ lib \ dt jar; C: \ Program Files \ Java \ jdk1.6.0 _21 \ lib \ tools. The jar
PATH = C: / Program Files/Java/jre6 / bin/client; C: / Program Files/Java/jre6 / bin; C: / Program Files/Java/jre6 / lib/i386. C:\Program Files\Common Files\Microsoft Shared\Windows Live; C: \ Program Files \ AMD APP \ bin \ x86. C: \ Windows \ system32; C: \ Windows; C: \ Windows \ System32 \ Wbem; C: \ Windows \ System32 \ WindowsPowerShell \ v1.0 \; C: \ Program Files \ ATI Technologies \ ATI ACE \ Core - Static; C: \ Program Files \ Common Files \ Lenovo; C: \ Program Files \ Common Files \ Ulead Systems \ MPEG; C: \ Program Files \ Windows Live \ Shared; C: \ SWTOOLS \ ReadyApps; C: \ Program Files \ Intel \ Services \ IPT \; C: \ Program Files \ Symantec VIP Access Client \ \; C: \ Program Files \ Java \ jdk1.6.0 _21 \ bin. C: \ Program Files \ Java \ jdk1.6.0 _21 \ jre6 \ bin. C: \ Program Files \ TortoiseSVN \ bin. C: \ Program Files \ Common Files \ Thunder Network \ KanKan \ Codecs
The USERNAME = think
OS = Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 42 Stepping 7, GenuineIntel
-- -- -- -- -- -- -- -- -- -- -- -- -- -- --   S Y S T E M  ---------------
OS: Windows 7 Build 7601 Service Pack 1
CPU:total 4 (8 cores per CPU, 2 threads per core) family 6 model 42 stepping 7, cmov, cx8, FXSR, MMX, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, ht
Memory: 4k page, physical 3056880k(1883100k free), swap 611200k (3307764k free)
Vm_info: Java HotSpot(TM) Client VM (17.0-b16) for windows-x86 JRE (1.6.0_21-b06), built on Jun 22 2010 00:56:49 by "java_re" with MS VC++ 7.1 (VS2003)
Time: Wed Apr 11 09:46:47 2012
Elapsed time: 0 seconds
Most of these errors are JNI side code problems, such as: inappropriate printf and cout calls, incompatible method call types, calls to destroyed objects, etc.

Related articles: