JDK-8049881 : jstack not working on core files
  • Type: Bug
  • Component: hotspot
  • Sub-Component: svc
  • Affected Version: 9
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2014-07-10
  • Updated: 2017-08-17
  • Resolved: 2014-07-22
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.
JDK 8 JDK 9
8u60Fixed 9 b26Fixed
Description
The change "8046282: SA update" introduced the following new code in
agent/src/share/classes/sun/jvm/hotspot/oops/Klass.java

+    traceIDField  = type.getField("_trace_id");

But I can not find the corresponding field in
src/share/vm/oops/klass.hpp. The Klass class only contains the macro
TRACE_DEFINE_KLASS_TRACE_ID which is defined to "typedef int
___IGNORED_hs_trace_type2" in traceMacros.hpp.

This leads to an error when calling for example jstack on a core file:

$ images/j2sdk-image/bin/jstack ./images/j2sdk-image/bin/java core
Attaching to core core from executable ./images/j2sdk-image/bin/java,
please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 1.9.0-internal-d046063_2014_07_10_11_16-b00
Deadlock Detection:

Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:484)
    at sun.tools.jstack.JStack.runJStackTool(JStack.java:140)
    at sun.tools.jstack.JStack.main(JStack.java:106)
Caused by: java.lang.ExceptionInInitializerError
    at sun.jvm.hotspot.oops.ObjectHeap.initialize(ObjectHeap.java:74)
    at sun.jvm.hotspot.oops.ObjectHeap.<init>(ObjectHeap.java:110)
    at sun.jvm.hotspot.runtime.VM.getObjectHeap(VM.java:582)
    at sun.jvm.hotspot.runtime.DeadlockDetector.print(DeadlockDetector.java:55)
    at sun.jvm.hotspot.runtime.DeadlockDetector.print(DeadlockDetector.java:39)
    at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:62)
    at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:45)
    at sun.jvm.hotspot.tools.JStack.run(JStack.java:66)
    at sun.jvm.hotspot.tools.Tool.startInternal(Tool.java:260)
    at sun.jvm.hotspot.tools.Tool.start(Tool.java:223)
    at sun.jvm.hotspot.tools.Tool.execute(Tool.java:118)
    at sun.jvm.hotspot.tools.JStack.main(JStack.java:92)
    ... 6 more
Caused by: java.lang.RuntimeException: field "_trace_id" not found in type Klass
    at sun.jvm.hotspot.types.basic.BasicType.getField(BasicType.java:183)
    at sun.jvm.hotspot.types.basic.BasicType.getField(BasicType.java:190)
    at sun.jvm.hotspot.types.basic.BasicType.getField(BasicType.java:194)
    at sun.jvm.hotspot.oops.Klass.initialize(Klass.java:58)
    at sun.jvm.hotspot.oops.Klass.access$000(Klass.java:33)
    at sun.jvm.hotspot.oops.Klass$1.update(Klass.java:37)
    at sun.jvm.hotspot.runtime.VM.registerVMInitializedObserver(VM.java:394)
    at sun.jvm.hotspot.oops.Klass.<clinit>(Klass.java:35)
    ... 18 more

Is this a problem with OpenJDK only (i.e. is '_trace_id' defined in
Oracle proprietary builds) ?. Or is this another problem?