JDK-6283361 : ManagementFactory.getCompilationMXBean() causes JVM crash
  • Type: Bug
  • Component: hotspot
  • Sub-Component: svc
  • Affected Version: 5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-06-09
  • Updated: 2010-04-02
  • Resolved: 2005-07-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6
5.0u6Fixed 6 b45Fixed
Description
FULL PRODUCT VERSION :
java version "1.5.0_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)

FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
I'm having Java thread which periodically queries some JVM statistics via MBeans API. This thread is started from native code (if it matters). Here is the first lines of "run" method:

  public void runImpl(){
    System.out.println("1");
    final CompilationMXBean compilationMXBean = ManagementFactory.getCompilationMXBean();
    System.out.println("2");
    final long totalCompilationTime = compilationMXBean.getTotalCompilationTime();
    System.out.println("totalCompilationTime = " + totalCompilationTime);
}

The problem is that JVM crashes immediately on line "compilationMXBean.getTotalCompilationTime()"

Here is ouput of JVM:
1
2
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d77340b, pid=860, tid=436
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_03-b07 mixed mode)
# Problematic frame:
# V  [jvm.dll+0xc340b]
#
# An error report file with more information is saved as hs_err_pid860.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#

The problem is also reproducible in latest "mustang" build.

THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: No

THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
yjpagent.dll is a JVMTI agent (my company is developing YourKit Java Profiler http://www.yourkit.com) which calls JNI method which starts Java thread

I'm running the following C:/jdk1.5.0_03/bin/java -agentlib:yjpagent -jar SwingSet2.jar

But JVM crashes with other JARs as well

ERROR MESSAGES/STACK TRACES THAT OCCUR :
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d77340b, pid=860, tid=436
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_03-b07 mixed mode)
# Problematic frame:
# V  [jvm.dll+0xc340b]
#

---------------  T H R E A D  ---------------

Current thread (0x00f35a88):  JavaThread "Thread-0" daemon [_thread_in_vm, id=436]

siginfo: ExceptionCode=0xc0000005, reading address 0x0000001c

Registers:
EAX=0x00000000, EBX=0x00000000, ECX=0x0000deab, EDX=0x00000000
ESP=0x0b24f8a4, EBP=0x0b24f8bc, ESI=0x00f35a88, EDI=0x00f35a88
EIP=0x6d77340b, EFLAGS=0x00010246

  Top of Stack: (sp=0x0b24f8a4)
0x0b24f8a4:   00f35a88 6d773201 00000008 00f35a88
0x0b24f8b4:   071690d8 071690d8 0b24f8f8 6d5220a6
0x0b24f8c4:   00f35b44 00000000 00000008 00f58749
0x0b24f8d4:   00f35b44 0b24f908 0b24f8dc 071690d8
0x0b24f8e4:   0b24f908 07169ea0 00000000 071690d8
0x0b24f8f4:   0b24f908 0b24f928 00f52caa 00000000
0x0b24f904:   00f56449 02fa2418 0b24f90c 071e4355
0x0b24f914:   0b24f930 071e45c8 00000000 071e4368

Instructions: (pc=0x6d77340b)
0x6d7733fb:   00 00 5e c3 e8 1e 01 00 00 5e c3 a1 28 eb 80 6d
0x6d77340b:   8b 48 1c 8b 01 ff 71 04 50 e8 70 17 00 00 59 59


Stack: [0x0b210000,0x0b250000),  sp=0x0b24f8a4,  free space=254k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [jvm.dll+0xc340b]
C  [management.dll+0x20a6]
j  sun.management.CompilationImpl.getTotalCompilationTime()J+21
j  com.yourkit.runtime.telemetry.TelemetryThread.runImpl()V+21
j  com.yourkit.runtime.telemetry.TelemetryThread.run()V+1
v  ~StubRoutines::call_stub
V  [jvm.dll+0x818b8]
V  [jvm.dll+0xd431d]
V  [jvm.dll+0x81789]
V  [jvm.dll+0x814e6]
V  [jvm.dll+0x9c06b]
V  [jvm.dll+0xfe7f5]
V  [jvm.dll+0xfe7c3]
C  [MSVCRT.dll+0x2a3b0]
C  [kernel32.dll+0xb50b]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  sun.management.VMManagementImpl.getTotalCompileTime()J+0
j  sun.management.CompilationImpl.getTotalCompilationTime()J+21
j  com.yourkit.runtime.telemetry.TelemetryThread.runImpl()V+21
j  com.yourkit.runtime.telemetry.TelemetryThread.run()V+1
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
=>0x00f35a88 JavaThread "Thread-0" daemon [_thread_in_vm, id=436]
  0x00f068c8 JavaThread "Finalizer" daemon [_thread_blocked, id=260]
  0x00f05438 JavaThread "Reference Handler" daemon [_thread_blocked, id=844]
  0x00035e70 JavaThread "main" [_thread_in_native, id=1496]

Other Threads:
  0x00f02b08 VMThread [id=1172]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
 def new generation   total 576K, used 446K [0x02f50000, 0x02ff0000, 0x03430000)
  eden space 512K,  87% used [0x02f50000, 0x02fbf930, 0x02fd0000)
  from space 64K,   0% used [0x02fd0000, 0x02fd0000, 0x02fe0000)
  to   space 64K,   0% used [0x02fe0000, 0x02fe0000, 0x02ff0000)
 tenured generation   total 1408K, used 0K [0x03430000, 0x03590000, 0x06f50000)
   the space 1408K,   0% used [0x03430000, 0x03430000, 0x03430200, 0x03590000)
 compacting perm gen  total 8192K, used 2641K [0x06f50000, 0x07750000, 0x0af50000)
   the space 8192K,  32% used [0x06f50000, 0x071e46c8, 0x071e4800, 0x07750000)
No shared spaces configured.

Dynamic libraries:
0x00400000 - 0x0040c000 	C:\jdk1.5.0_03\bin\java.exe
0x7c900000 - 0x7c9b1000 	C:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c8f6000 	C:\WINDOWS\system32\kernel32.dll
0x77dc0000 - 0x77e6c000 	C:\WINDOWS\system32\ADVAPI32.dll
0x77e70000 - 0x77f01000 	C:\WINDOWS\system32\RPCRT4.dll
0x77c00000 - 0x77c58000 	C:\WINDOWS\system32\MSVCRT.dll
0x6d6b0000 - 0x6d836000 	C:\jdk1.5.0_03\jre\bin\client\jvm.dll
0x77d30000 - 0x77dc0000 	C:\WINDOWS\system32\USER32.dll
0x77f10000 - 0x77f56000 	C:\WINDOWS\system32\GDI32.dll
0x76b20000 - 0x76b4e000 	C:\WINDOWS\system32\WINMM.dll
0x6d2f0000 - 0x6d2f8000 	C:\jdk1.5.0_03\jre\bin\hpi.dll
0x76be0000 - 0x76beb000 	C:\WINDOWS\system32\PSAPI.DLL
0x008a0000 - 0x0091f000 	C:\Documents and Settings\vova\projects\frekenbok\bin\win32\yjpagent.dll
0x71ab0000 - 0x71aba000 	C:\WINDOWS\system32\WSOCK32.DLL
0x71a90000 - 0x71aa7000 	C:\WINDOWS\system32\WS2_32.dll
0x71a80000 - 0x71a88000 	C:\WINDOWS\system32\WS2HELP.dll
0x6d680000 - 0x6d68c000 	C:\jdk1.5.0_03\jre\bin\verify.dll
0x6d370000 - 0x6d38d000 	C:\jdk1.5.0_03\jre\bin\java.dll
0x6d6a0000 - 0x6d6af000 	C:\jdk1.5.0_03\jre\bin\zip.dll
0x6d530000 - 0x6d543000 	C:\jdk1.5.0_03\jre\bin\net.dll
0x71a30000 - 0x71a70000 	C:\WINDOWS\system32\mswsock.dll
0x698b0000 - 0x69908000 	C:\WINDOWS\system32\hnetcfg.dll
0x71a70000 - 0x71a78000 	C:\WINDOWS\System32\wshtcpip.dll
0x6d520000 - 0x6d528000 	C:\jdk1.5.0_03\jre\bin\management.dll

VM Arguments:
jvm_args: -agentlib:yjpagent
java_command: SwingSet2.jar

Environment Variables:
PATH=C:\Program Files\Far;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\bin;C:\Program Files\BCC55\bin;C:\Program Files\WinRAR;C:\gnupg;C:\Program Files\cvsnt;C:\mysql\bin;C:\Program Files\Microsoft Visual Studio 8\Performance Tools\;C:\Program Files\Microsoft SQL Server\90\Tools\BinnUSERNAME=vova
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 10 Stepping 0, AuthenticAMD


---------------  S Y S T E M  ---------------

OS: Windows XP Build 2600 Service Pack 2

CPU:total 1 family 6, cmov, cx8, fxsr, mmx, sse

Memory: 4k page, physical 1048048k(495628k free), swap 2520664k(2034320k free)

vm_info: Java HotSpot(TM) Client VM (1.5.0_03-b07) for windows-x86, built on Apr 13 2005 02:07:01 by "java_re" with MS VC++ 6.0



REPRODUCIBILITY :
This bug can be reproduced always.
###@###.### 2005-06-09 18:35:05 GMT

Comments
SUGGESTED FIX In src/share/vm/compiler/compileBroker.hpp *** 300,304 **** // Return total compilation ticks static jlong total_compilation_ticks() { ! return _perf_total_compilation->get_value(); } --- 300,304 ---- // Return total compilation ticks static jlong total_compilation_ticks() { ! return _perf_total_compilation != NULL ? _perf_total_compilation->get_value() : 0; } ###@###.### 2005-07-20 17:58:08 GMT
19-07-2005

EVALUATION I suspect it could be a timing issue related to the agentlib that starts a Java thread. A simple Java program calling the same method works fine. ###@###.### 2005-06-09 19:09:37 GMT The jvmti VM_INIT event is posted before the compiler initializes where it records the compilation statistics. Will fix it in Mustang and Tiger update. We can't reproduce the crash in-house but we identified the bug by code inspection. The submitter has verified that the proposed bug fix resolved the problem. ###@###.### 2005-07-19 00:16:16 GMT
09-06-2005