JDK-8145741 : jstack throws NullPointerException
  • Type: Bug
  • Component: hotspot
  • Sub-Component: svc-agent
  • Affected Version: 8u66,11
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_8
  • CPU: x86_64
  • Submitted: 2015-12-18
  • Updated: 2018-06-11
  • Resolved: 2018-06-06
Related Reports
Duplicate :  
Description
Under uncertain conditions it can happen that jstack is throwing a NullPointerException:

java.lang.NullPointerException
        at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:88)
        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)
        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:497)
        at sun.tools.jstack.JStack.runJStackTool(JStack.java:140)
        at sun.tools.jstack.JStack.main(JStack.java:106)
 
I discoveres this when I had running jstack in a bash-driven loop to produce a series of stack snapshots while trying to force a particular failure scenario in the observed VM.

Unfortunately I cannot tell how a generic way to produce this could look like, so presumably it will be best to simply perform a "blind" code review using the above stack trace.
Comments
Looks like a duplicate of https://bugs.openjdk.java.net/browse/JDK-8196969 (JTreg Failure: serviceability/sa/ClhsdbJstack.java causes NPE)
06-06-2018

Reproduced in JDK 11 by test serviceability/sa/ClhsdbJdis.java
06-06-2018

Hi Unfortunately, the stack trace doesn't give much. The code around it is: 85 try { 86 for (JavaVFrame vf = cur.getLastJavaVFrameDbg(); vf != null; vf = vf.javaSender()) { 87 Method method = vf.getMethod(); 88 tty.print(" - " + method.externalNameAndSignature() + 89 " @bci=" + vf.getBCI()); Probably, vf.getMethod() returns null, but without a reproducer it is hard to say why.
04-01-2016