JVM Crash原因分析及相关资料(转)

JVM Crash原因分析及相关资料(转)

转自:http://seanhe.iteye.com/blog/905997

去年生产环境突然有一天连续发生几台服务器JVM Crash的情况。出现这种情况的时候JVM留下的error log基本相同 
Java代码  收藏代码
#  
# A fatal error has been detected by the Java Runtime Environment:  
#  
#  SIGSEGV (0xb) at pc=0x00002b28192a24f0, pid=28485, tid=1088477504  
#  
# JRE version: 6.0_18-b07  
# Java VM: Java HotSpot(TM) 64-Bit Server VM (16.0-b13 mixed mode linux-amd64 )  
# Problematic frame:  
# V  [libjvm.so+0x5c04f0]  
#  
# If you would like to submit a bug report, please visit:  
#   http://java.sun.com/webapps/bugreport/crash.jsp  
#  
  
---------------  T H R E A D  ---------------  
  
Current thread (0x00002aab4803e800):  JavaThread "CompilerThread1" daemon [_thread_in_native, id=28511, stack(0x0000000040d0d000,0x0000000040e0e000)]  
  
siginfo:si_signo=SIGSEGV: si_errno=0, si_code=1 (SEGV_MAPERR), si_addr=0x000000000000002c  
  
此处略去N个字...  
  
Current CompileTask:  
C2:171% !   org.mule.esb.impl.core.provider.spring.EsbClientBean.invoke(Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object; @ 56 (492 bytes)  
  
再次略去N个字...  


巧合的是crash时JVM都在做同一件事情“Current CompileTask: 
C2:171% !   org.mule.esb.impl.core.provider.spring.EsbClientBean.invoke(Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object; @ 56 (492 bytes)” 
显示JIT在做编译优化的时候处理.EsbClientBean.invoke这个方法时出错。幸好SUN(Oracle)提供了相关的文档说明,得以让我们解决了这个问题。 
文档地址:http://www.oracle.com/technetwork/java/javase/crashes-137240.html#gbyzu 
引用

If the fatal error log output shows that the Current thread is a JavaThread named CompilerThread0, CompilerThread1, or AdapterCompiler, then it is possible that you have encountered a compiler bug. In this case it might be necessary to temporarily work around the issue by switching the compiler (for example, by using the HotSpot Client VM instead of the HotSpot Server VM, or visa versa), or by excluding from compilation the method that provoked the crash. This is discussed in   4.2.1 Crash in HotSpot Compiler Thread or Compiled Code. 

原文的意思简单的说:当在错误日志中显示“the Current thread is a JavaThread named CompilerThread0, CompilerThread1, or AdapterCompiler”时,可能是触发了JVM的编译器的BUG导致的。 

解决办法见这里的描述http://www.oracle.com/technetwork/java/javase/crashes-137240.html#gbyzd 
主要有两类: 
1.JVM使用client模式,即去掉“-server”参数改用“-client” 
2.过滤掉会导致JVM crach的一些方法不执行编译优化。具体有两种做法:a.在程序的工作路径创建.hotspot_compiler文件,文件内容类似这样: 
Java代码  收藏代码
exclude org/mule/esb/impl/core/provider/spring/EsbClientBean invoke  
。b.在jvm启动参数中添加启动参数 
Java代码  收藏代码
-XX:CompileCommand=exclude,org/mule/esb/impl/core/provider/spring/EsbClientBean,invoke   
可以达到同样的效果。 

因为第一类解决方法会整体影响应用服务器的性能,所以我们没有采用。第二类方法里我选择了b这种方式,修改启动脚本比较方便。 

通过这次问题的解决,积累了一些资料可以供以后再解决此类问题。 
1.一些常见的crash原因:http://www.oracle.com/technetwork/java/javase/crashes-137240.html 
2.JVM crash error log format:http://www.oracle.com/technetwork/java/javase/felog-138657.html

猜你喜欢

转载自java12345678.iteye.com/blog/2395085
今日推荐