Java堆分析与SIGABRT一起崩溃

时间:2018-12-20 07:04:19

标签: java jvm profiling heap

我正在尝试分析由C编写的方法分配的本机内存,并通过JVM插入JNI。我安装了

$ valgrind --version
valgrind-3.13.0

并尝试使用以下选项运行JVM:

valgrind --tool=massif --massif-out-file=/tmp/massif-j.out java 
    -XX:+UnlockDiagnosticVMOptions //...

问题是它在创建核心转储时崩溃了

  0x00000000080e4196: fxrstor64 (%rsp)
  0x00000000080e419b: add     $0x200,%rsp
  0x00000000080e41a2: mov     (%rsp),%r15
  0x00000000080e41a6: mov     0x8(%rsp),%r14
  0x00000000080e41ab: mov     0x10(%rsp),%r13
  0x00000000080e41b0: mov     0x18(%rsp),%r12
  0x00000000080e41b5: mov     0x20(%rsp),%r11
  0x00000000080e41ba: mov     0x28(%rsp),%r10
  0x00000000080e41bf: mov     0x30(%rsp),%r9
  0x00000000080e41c4: mov     0x38(%rsp),%r8
  0x00000000080e41c9: mov     0x40(%rsp),%rdi
  0x00000000080e41ce: mov     0x48(%rsp),%rsi
  0x00000000080e41d3: mov     0x50(%rsp),%rbp
  0x00000000080e41d8: mov     0x60(%rsp),%rbx
  0x00000000080e41dd: mov     0x68(%rsp),%rdx
  0x00000000080e41e2: mov     0x70(%rsp),%rcx
  0x00000000080e41e7: mov     0x78(%rsp),%rax
  0x00000000080e41ec: add     $0x80,%rsp
  0x00000000080e41f3: add     $0x8,%rsp
  0x00000000080e41f7: Fatal error: Disassembling failed with error code: 15#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (sharedRuntime.cpp:834), pid=12441, tid=0x0000000021385700
#  fatal error: exception happened outside interpreter, nmethods and vtable stubs at pc 0x00000000080e4147
#
# JRE version: Java(TM) SE Runtime Environment (8.0_181-b13) (build 1.8.0_181-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.181-b13 mixed mode linux-amd64 compressed oops)
# Core dump written. Default location: /var/log/prj/core or core.12441
#
# An error report file with more information is saved as:
# /var/log/prj/hs_err_pid12441.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
#
==12441==
==12441== Process terminating with default action of signal 6 (SIGABRT): dumping core
==12441==    at 0x54AAE97: raise (raise.c:51)
==12441==    by 0x54AC800: abort (abort.c:79)
==12441==    by 0x658B3C4: ??? (in /usr/lib/jvm/java-oracle-8-amd64/jdk/jre/lib/amd64/server/libjvm.so)
==12441==    by 0x672F5B2: ??? (in /usr/lib/jvm/java-oracle-8-amd64/jdk/jre/lib/amd64/server/libjvm.so)
==12441==    by 0x615EE98: ??? (in /usr/lib/jvm/java-oracle-8-amd64/jdk/jre/lib/amd64/server/libjvm.so)
==12441==    by 0x662A099: ??? (in /usr/lib/jvm/java-oracle-8-amd64/jdk/jre/lib/amd64/server/libjvm.so)
==12441==    by 0x6591A49: JVM_handle_linux_signal (in /usr/lib/jvm/java-oracle-8-amd64/jdk/jre/lib/amd64/server/libjvm.so)
==12441==    by 0x6587652: ??? (in /usr/lib/jvm/java-oracle-8-amd64/jdk/jre/lib/amd64/server/libjvm.so)
==12441==    by 0x4E4588F: ??? (in /lib/x86_64-linux-gnu/libpthread-2.27.so)
==12441==    by 0x80E4146: ???
==12441==    by 0x107: ???
==12441==    by 0x84CBC43: ???
==12441==    by 0x10001BD37: ???
==12441==    by 0xFDC7103F: ???
==12441==    by 0xA3FFFFFFFF: ???
==12441==    by 0xFF9275A7: ???
==12441==

任何人都可以提出可能出什么问题的想法吗?是因为Fatal error: Disassembling failed with error code: 15#吗?

1 个答案:

答案 0 :(得分:2)

具有自我修改代码的Valgrind(和基于Valgrind的工具)does not work well。但是,HotSpot JVM严重依赖于动态代码生成,包括覆盖和修补先前生成的指令。即使在禁用JIT编译器的情况下,这一点仍然成立,因为HotSpot还将动态代码生成用于解释器和运行时存根。

对于本机内存分配分析,您也可以使用jemallocasync-profiler。后者具有与Java运行时集成的优势,即它可以显示带有本机框架和Java框架的混合堆栈跟踪。此外,与Valgrind虚拟化正在运行的程序相比,这两种工具的性能开销都相当小。

有关更多信息,请参见thisthis答案。