核心转储发生在Java本机方法中

huangapple go评论80阅读模式
英文:

Core dump happens in Java native method

问题

我的项目是一个Spring Boot项目,运行在K8s的Pod中。遇到了一个错误,以下是日志文件的头部信息:

# Java运行环境检测到了一个致命错误:
#
#  在pc=0x00007f116f6b1be1处发生SIGSEGV错误(0xb),pid=516,tid=0x00007f10795ef700
#
# JRE版本:OpenJDK Runtime Environment(8.0_121-b13)(构建1.8.0_121-8u121-b13-0ubuntu1.16.04.2-b13)
# Java虚拟机:OpenJDK 64位服务器VM
# 有问题的帧:
# C  [libc.so.6+0x95bd3]  strchrnul+0x23
#
# 核心转储已写入。默认位置:/projects/core.dump

然后我尝试获取core.dump文件,它的大小为5G。我的项目通过.so文件调用了C本地方法,其中不包括main方法,所以无法编译获取.exe.out文件。在尝试了以下方法后,我不知道如何分析dump文件:

gdb [exe文件] [core文件](可以获取exe文件)
gdb java core.dump
jmap -dump:format=b,file=./2842.hprof $JAVA_HOME/bin/java core.dump

我该如何分析core.dump以定位问题呢?

英文:

My project is a spring boot project and run in K8s pod. An error encountered and this is header of the log file:

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f116f6b1be1, pid=516, tid=0x00007f10795ef700
#
# JRE version: OpenJDK Runtime Environment (8.0_121-b13) (build 1.8.0_121-8u121-b13-0ubuntu1.16.04.2-b13)
# Java VM: OpenJDK 64-Bit Server VM 
# Problematic frame:
# C  [libc.so.6+0x95bd3]  strchrnul+0x23
#
# Core dump written. Default location: /projects/core.dump

Then I try to get the file core.dump, its size is 5G. And my project invoke the C native method through .so file, which doesn't include method main , so I cann't compile to get the .exe or .out. I don't know how to analyze the dump file after trying these method:

gdb [exe file] [core file](can get the exe file)
gdb java core.dump
jmap -dump:format=b,file=./2842.hprof $JAVA_HOME/bin/java core.dump

How can I analyze the core.dump the locate the problem?

答案1

得分: 1

在Windows系统中,如果您遇到问题,可以使用WinDbg轻松调试转储文件。您可以尝试使用WinDbg预览版 - 我正在使用它来调试Java核心转储文件。
您可以在此处下载它:https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-download-tools

然后,只需执行!analyze -v作为您的第一个命令,您将获得大量有用的信息。我曾经处理过40GB的转储文件,所以5GB应该没问题。
当然,您需要选择正确的线程,例如这是来自我的线程java.exe!main的堆栈信息:

核心转储发生在Java本机方法中

英文:

Supposing you are in Windows then you can easily debug dumps with WinDbg. You can try WinDbg Preview - I am using this to debug Java core dumps.
You can download it here https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-download-tools

Then just run !analyze -v as your first command and you get lot of useful information. I had 40G dumps so 5G should be fine.
Of course you have to choose right thread, e.g. here is stack from my thread java.exe!main:

核心转储发生在Java本机方法中

huangapple
  • 本文由 发表于 2020年9月30日 17:29:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/64134676.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定