Java堆分析与SIGABRT一起崩溃 [英] Java heap profiling crashes with SIGABRT
问题描述
我正在尝试分析由C编写的方法分配并通过JNI
插入到JVM
的本机内存.我安装了
I'm trying to profile native memory allocated by C-written methods and plugged to JVM
through JNI
. I installed
$ valgrind --version
valgrind-3.13.0
并尝试使用以下选项运行JVM:
And tried to run JVM with the following options:
valgrind --tool=massif --massif-out-file=/tmp/massif-j.out java
-XX:+UnlockDiagnosticVMOptions //...
问题是它在创建核心转储时崩溃了
The thing is it crashes with core dump created
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#
吗?
Can anyone give an idea of what could go wrong? Is that because of Fatal error: Disassembling failed with error code: 15#
?
推荐答案
Valgrind(和基于Valgrind的工具)不能与自修改代码配合使用.但是,HotSpot JVM严重依赖于动态代码生成,包括覆盖和修补先前生成的指令.即使在禁用JIT编译器的情况下,这一点仍然成立,因为HotSpot还将动态代码生成用于解释器和运行时存根.
Valgrind (and Valgrind-based tools) does not work well with self-modifying code. However, HotSpot JVM heavily relies on dynamic code generation, including overwriting and patching the previously generated instructions. This holds even when JIT compiler is disabled, because HotSpot also uses dynamic code generation for interpreter and runtime stubs.
对于本机内存分配分析,您还可以使用 jemalloc 或
For native memory allocation profiling you may also use jemalloc or async-profiler. The latter has the advatange of integration with Java runtime, i.e. it can show mixed stack traces with both native and Java frames. Furthermore, both tools have rather small performance overhead unlike Valgrind which virtualizes the running program.
有关更多信息,请参见此和
For more information see this and this answers.
这篇关于Java堆分析与SIGABRT一起崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!