1

I have a program written in C++, it will use JNI to launch a JVM and run the java code. But now the program crashed and generate a core file.

When I attach the core with the gdb by `gdb <my_program> , only the top two frames are shown, and others are ??

(gdb) bt
#0  0x00007f635bf98596 in __memmove_avx_unaligned () from /var/lib/jenkins/Projects/libc.so.6
#1  0x00007f634aa1d142 in Unsafe_CopyMemory0 () from /RELEASE/BIN/Linux/_jre/lib/server/libjvm.so
#2  0x00007f63285c20a4 in ?? ()
#3  0x00000000000014ea in ?? ()
#4  0x00000000b5330948 in ?? ()
#5  0x0000000000000000 in ?? ()

I think those ?? are java stack trace, I try to print them with jstack <my_program> <core>, but it errs as follow

Error: More than one non-option argument
Cannot connect to the core dump or remote debug server. Use jhsdb jstack instead

I also tried jhsdb jstack --exe <my_pogram> --core <core>, but get the following error

Error attaching to core file: Can't attach to the core file
sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the core file
        at jdk.hotspot.agent/sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.attach0(Native Method)
        at jdk.hotspot.agent/sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.attach(LinuxDebuggerLocal.java:282)
        at jdk.hotspot.agent/sun.jvm.hotspot.HotSpotAgent.attachDebugger(HotSpotAgent.java:674)
        at jdk.hotspot.agent/sun.jvm.hotspot.HotSpotAgent.setupDebuggerLinux(HotSpotAgent.java:612)
        at jdk.hotspot.agent/sun.jvm.hotspot.HotSpotAgent.setupDebugger(HotSpotAgent.java:338)
        at jdk.hotspot.agent/sun.jvm.hotspot.HotSpotAgent.go(HotSpotAgent.java:305)
        at jdk.hotspot.agent/sun.jvm.hotspot.HotSpotAgent.attach(HotSpotAgent.java:157)
        at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.start(Tool.java:191)
        at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.execute(Tool.java:118)
        at jdk.hotspot.agent/sun.jvm.hotspot.tools.JStack.runWithArgs(JStack.java:90)
        at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.runJSTACK(SALauncher.java:297)
        at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.main(SALauncher.java:533)

Is there a way to print those ?? frames?

Updated

After debugging the jhsdb, the cause of failure of attaching to the the core file is the interpreter cannot be located telled by the following code

  // now read segments from interp (i.e ld.so or ld-linux.so or ld-elf.so)
  if (read_interp_segments(ph) != true) {
      return false;
  }

And after reading the source code of JDK, I find the following env variable can print more information

{
                "name": "LIBSAPROC_DEBUG",
                "value": "DEBGUG"
            }
EvanL00
  • 370
  • 3
  • 13

0 Answers0