Java Crash Analysis [z]




If you do not know what causes the Java process exits or killed, you want to analyze the specific reasons, in general, the following sub-steps:

A Java application to get the log file.
Generally speaking, the log file will be very application-related error messages. Causes abnormal exit the Java process is most likely that the application itself. So check the log files for Java applications is probably the fastest way to locate the error.

2 Find the JVM fatal error log if the application log file not found any clues. You can also view the JVM fatal error log. Some fatal errors, such as JNI or virtual machine itself wrong, could make time to write Java applications out of the log. At this time you can check a "hs_err_pid" at the beginning of the log name, such as hs_err_pid1125.log, of which 1125 is the process number. The document also records some valuable information to provide some clues, especially some of Java's own Bug. This file is generally in the current working directory. Users can use their own search to find command.

3 to find the operating system core dump file is operating system as the scheduling process, Java process will be produced under the different signals Core Dump file, such as Sig_ill and Seg_segv. These are very serious mistake indeed no time to make the Java Virtual Machine log on any of the dang. Get a core dump file can use many tools to analyze the specific reasons, for example jmap, jstack friendly so you can make the process of Core Java file analysis. In general, Core files into the process's current working directory, the user can use the find command to search for "core". Also can be used to pre-specified core file coreadm storage areas and file name format, such as: coreadm-g / var / core / core.% F.% p.% t

4 Use Dtrace find "Who killed the Java process"
However, there are many cases, the process is killed and the reasons are complex. There may be other than kill the process, or accidentally kill off some scripting, or by the administrator (or intruders kill -9) to dispose of. These conditions will not produce the log file and core dump files. The situation is difficult to track. But if Solaris10, you can use the following Dtrace script to determine "who is killing the Java process."

#! / Usr / sbin / dtrace-qs

proc::: signal-send
/ Args [1] -> pr_pid == $ 1 /
printf ("% s (pid:% d) is sending signal% d to% s" n ", execname, pid, args [2], args [1] -> pr_fname);

How to Run (1125) is the process number
$ ./sig1.d 1125
sched (pid: 0) is sending signal 24 to bc
sched (pid: 0) is sending signal 24 to bc
bash (pid: 3987) is sending signal 15 to bc
bash (pid: 3987) is sending signal 15 to bc
bash (pid: 3987) is sendg signal 9 to bc

Java application for various reasons, sometimes because of Crash, this time will produce a similar java_errorpid.log error log. You can get this log, how to analyze Crash cause? Let us discuss in detail how to analyze java_errorpid.log error log.
I. How to get the log file if there is a serious error caused by the Java process exits abnormally, we called Crash, this time will produce a log file. By default, this file will be generated in the working directory. However, the Java startup parameters through the following settings to change the file location and naming rules. For example:
java-XX: ErrorFile = / var / log / java / java_error_% p.log
The error file will be placed in / var / log / java under, and to java_error_pid.log form.

II. Cause of the error cause serious errors are possible. Java Virtual Machine Bug is one of the reasons of their own, but this may not be great. In most cases, is due to system libraries, API or third-party library files created; system resource shortages may cause such a serious error. In the event of a Crash, if unable to locate the root cause, it should quickly find the Work Around method.

III. The analysis of the log file first to check the log file header: for example, the following is sent from a client over the error log file header -------------------- -----------------
# An unexpected error has been detected by HotSpot Virtual Machine:
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc = 0x0815e87e, pid = 7268, tid = 4360
# Java VM: Java HotSpot (TM) Server VM (1.4.2_13-b06 mixed mode)
# Problematic frame:
# V [jvm.dll +0 x15e87e]

Header has a lot of useful information, "EXCEPTION_ACCESS_VIOLATION" means that Java applications Crash when running JVM own code, rather than external Java code libraries or other code. This situation is likely to be the JVM Bug, but not necessarily. In addition to "EXCEPTION_ACCESS_VIOLATION", there may be other information, such as "SIGSEGV (0xb)", means that the JVM is running locally or JNI code; "EXCEPTION_STACK_OVERFLOW" means that this is a stack overflow error.

Another useful information is:
# Problematic frame:
# V [jvm.dll +0 x15e87e]

It shows when Crash, JVM is executing code from which the library files. In addition to "V", there may be "C", "j", "v", "J". Specific meaning that is as follows:
FrameType Description:
C: Native C frame
j: Interpreted Java frame
V: VMframe
v: VMgenerated stub frame
J: Other frame types, including compiled Java frames

After the header, the current thread DUMP information, threads DUMP JVM process followed, including the status of all threads, address and ID. Finally, there JVM state, Heap state, dynamic link libraries, etc. information. These disturbing information, contains very useful information. Here we have a few specific examples according to the analysis of Java Virtual Machine Crash typical example.

IV. Memory recovery memory recovery caused by Crash Crash caused by the following characteristics: the log file header generally "EXCEPTION_ACCESS _VIOLATION" and "# Problematic frame: # V [jvm.dll +...." information, means that is handled internally in the JVM, and most of the JVM the Bug. For such problems, the fastest way is to bypass it.
In addition, the DUMP Thread Information Finally, you can still see the behavior of the garbage collection example:
--------------- THREAD ---------------
Current thread (0x00a56668): VMThread [id = 4360]
sig** ExceptionCode = 0xc0000005, reading address 0x00000057

Stack: [0x03cf0000, 0x03d30000), sp = 0x03d2fc18, free space = 255k
Native frames: (J = compiled Java code, j = interpreted, Vv = VM code, C = native code)
V [jvm.dll +0 x15e87e]

VM_Operation (0x063efbac): full generation collection, mode: safepoint, requested by thread 0x040f83f8
-------------------------------------------------- ----------

Can clearly see the JVM is doing "full generation collection". There are also likely to see other recovery actions:

generation collection for allocation
full generation collection
parallel gc failed allocation
parallel gc failed permanent allocation
parallel gc system gc

For the recovery of memory error, in general, change the recovery algorithm and parameters of methods to go around. For example, the log from the client in addition to the above log information in the log information Heap also find some additional information:
-------------------------------------------------- ------------
def new generation total 22592K, used 19530K [0x10010000, 0x11890000, 0x138f0000)
eden space 20096K, 97% used [0x10010000, 0x11322bd8, 0x113b0000)
from space 2496K, 0% used [0x113b0000, 0x113b0000, 0x11620000)
to space 2496K, 0% used [0x11620000, 0x11620000, 0x11890000)
tenured generation total 190696K, used 100019K [0x138f0000, 0x1f32a000, 0x30010000)
the space 190696K, 52% used [0x138f0000, 0x19a9cf38, 0x19a9d000, 0x1f32a000)
compacting perm gen total 38656K, used 38588K [0x30010000, 0x325d0000, 0x34010000)
the space 38656K, 99% used [0x30010000, 0x325bf038, 0x325bf200, 0x325d0000)
-------------------------------------------------- --------------

The above information can be seen when in Crash, JVM's PermSize space consumed almost finished, and the recovery algorithm in the compressed space of time Perm went wrong. Therefore, the proposed change memory recovery algorithms, or expand PermSize and MaxPermSize values.

V. stack overflow due to stack overflow caused CrashJava code usually does not cause the JVM Crash, but throws a Java exception: java.lang.StackOverflowError. But in the Java Virtual Machine, Java code and native C or C + + code to the public the same Stack. Thus, in the implementation of native code resulting stack overflow may cause the JVM Crash of.
Crash caused by stack overflow in the log file header to see "EXCEPTION_STACK_OVERFLOW" word. In addition, the current thread's Stack information can be found in some of the information. For example, the following examples:
-------------------------------------------------- ---------------------------------

In the above information, you can find this is a stack overflow error. And the current stack the remaining space is very small (free space = 4k). Therefore proposed to adjust the size of the JVM Stack large, two main design parameters: "-Xss" and "-XX: StackShadowPages = n". However, the size of the stack to transfer large, also means that the limited memory resources, to open the maximum number of threads will be reduced.
标签: quot, java virtual machine, java application, application log, operating system, core files, error messages, java applications, www1, java file, core java, core core, fatal error, java process, storage areas, core index, directory users, dang, core dump, crash analysis
分类: Internet
时间: 2011-03-23


  1. Crash Analysis Tool using the Linux dump file

    Preface Linux kernel (the core) is a process not associated with a particular feature set, the kernel code is ...
  2. [Java Performance Analysis] Introduction

    Java performance analysis of the recent study's theme, theories related to Sun JVM memory management and garba ...
  3. a detailed analysis of java crash

    1. How do I get this log file if there is a serious error caused by Java process in the non-normal exit, we ca ...
  4. JAVA crash investigation methods after incomplete

    Print GC, memory overflow dump -server -Xms512m -Xmx512m -XX:NewSize=107m -XX:MaxNewSize=107m -XX:+UseConcMark ...
  5. Java code analysis tool for the problem of effective java thread dump

    Analysis of Java code to the most effective tool is still java thread dump, the support staff is particularly ...
  6. Java Memory Analysis (Reprinted)

    In JAVA, there are six different places to store data: 1. Register (register). This is the fastest storage are ...
  7. java extract. tar. Z files Uncompress a unix compressed file -. Z

    . Tar extract: . Z decompression: Java Programming - Uncompress a ...
  8. [Java performance analysis] JPDA 1) the overall structure

    JPDA (Java Platform Debugger Architecture) provides a JVM internal access interface, so that we can easily und ...
  9. [Java performance analysis] JPDA 2) JVM TI

    Reference: JVM JVM TI for external access through ...
  10. [Java performance analysis] Sun JDK introduces the basic performance analysis tools

    Sun JDK version also released with a number of performance analysis tools, these tools are essentially based o ...
  11. [Java performance analysis] Sun JDK visual performance analysis tools introduced

    In addition to some basic tools, together with the Sun JDK release some visual analysis tools, including in th ...
  12. [Java performance analysis] Eclipse Memory Analyzer description

    Eclipse Memory Analyzer is a great heap memory analysis tool, JDK comes with a heap analysis tool jhat's a ver ...
  13. [Java performance analysis] TPTP profiling Introduction

    TPTP (Test & Performance Tool Platform) is another test Eclipse / performance analysis of the masterpiece, ...
  14. JAVA memory analysis

    VM JDK comes with analysis tools jps, jstat, jmap, jconsole special other strong, there are numerous options, ...
  15. [Jia Wen Dramas] kernel read from the java performance analysis and design

    Transfer from: Introduction java since the emer ...
  16. JProbe-Java memory analysis. Java performance analysis. Java Coverage Analysis

    JProbe provides three types of analysis: Memory analysis, so that developers can identify and solve Java memor ...
  17. [转]Java Crash原因汇总

    如果是Java进程不知道什么原因退出或被杀死,想要分析具体原因,一般来说分下面几步: 1. 拿到Java应用程序的日志文件 2. 查找JVM的致命错误日志 3. 查找操作系统的core dump文件 4. 使用Dtrac ...
  18. JAVA garbled Analysis

    UNICODE encoding, it uses double-byte encoding, compatible with English characters and other nationalities dou ...
  19. Java: Performance Analysis of collections [change]

    This article is transferred, and no verification of the correctness of the article, I have time will be carefu ...