转帖-大对象导致JVM Crash (Jboss) 分析及解决 - JDK 已知bug

本文记录了一次JVM Crash的故障排查过程,详细分析了hs_err_pid.log文件,最终定位到Young GC期间发生的异常,并给出了通过设置-XX:-ReduceInitialCardMarks参数来规避问题的方法。

最近在一个项目中,web 应用跑一段时间后, JBoss JVM crash ,web日志中没有任何异常。

存放日志的地方发现有 hs_err_pid25052.log,发现这个文件,就知道是JVM crash了。

打开这个文件然后分析:

Log代码 收藏代码
  1. --------------- T H R E A D ---------------
  2. Current thread (0x0000000050682000): GCTaskThread [stack: 0x00000000413fb000,0x00000000414fc000] [id=25059]
  3. siginfo:si_signo=SIGSEGV: si_errno=0, si_code=1 (SEGV_MAPERR), si_addr=0x0000000000000018
  4. Registers:
  5. 此处省略.........
  6. Top of Stack: (sp=0x00000000414fae70)
  7. 此处省略.........
  8. Instructions: (pc=0x00002aaffd33163c)
  9. 此处省略.........
  10. Stack: [0x00000000413fb000,0x00000000414fc000], sp=0x00000000414fae70, free space=3ff0000000000000018k
  11. Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
  12. V [libjvm.so+0x62263c]
  13. V [libjvm.so+0x6230b0]
  14. V [libjvm.so+0x625672]
  15. V [libjvm.so+0x365dda]
  16. V [libjvm.so+0x5da2af]

分析1:JVM crash时,执行的线程GCTaskThread;V [libjvm.so+0x62263c]
代表执行的是VM代码,也就是说执行虚拟机的代码时JVM crash的。

Log代码 收藏代码
  1. --------------- P R O C E S S ---------------
  2. Java Threads: ( => current thread )
  3. 0x00000000517fe800 JavaThread "notifier[172.29.63.18:9090]104" daemon [_thread_blocked, id=27922, stack(0x000000004c36d000,0x000000004c46e000)]
  4. 0x0000000050f35000 JavaThread "RpcClientIoHandlerImpl-processor-106" daemon [_thread_blocked, id=27921, stack(0x000000004db85000,0x000000004dc86000)]
  5. 此处省略.........
  6. Other Threads:
  7. 0x00000000506d2000 VMThread [stack: 0x0000000040b6a000,0x0000000040c6b000] [id=25062]
  8. 0x0000000050713800 WatcherThread [stack: 0x000000004085f000,0x0000000040960000] [id=25069]
  9. =>0x0000000050682000 (exited) GCTaskThread [stack: 0x00000000413fb000,0x00000000414fc000] [id=25059]

分析2:这里日志是当前所有的Thread的列表。exited标示说明这个是执行线程。

Java代码 收藏代码
  1. VM state:at safepoint (normal execution)
  2. VM Mutex/Monitor currently owned by a thread: ([mutex/lock_event])
  3. [0x0000000050663370] Threads_lock - owner thread: 0x00000000506d2000
  4. [0x0000000050663870] Heap_lock - owner thread: 0x00000000517c4800
  5. Heap
  6. PSYoungGen total 43328K, used 43136K [0x00002aaacb760000, 0x00002aaace200000, 0x00002aaad6200000)
  7. eden space 43008K, 100% used [0x00002aaacb760000,0x00002aaace160000,0x00002aaace160000)
  8. from space 320K, 40% used [0x00002aaace1b0000,0x00002aaace1d0000,0x00002aaace200000)
  9. to space 320K, 40% used [0x00002aaace160000,0x00002aaace180000,0x00002aaace1b0000)
  10. PSOldGen total 349568K, used 119371K [0x00002aaab6200000, 0x00002aaacb760000, 0x00002aaacb760000)
  11. object space 349568K, 34% used [0x00002aaab6200000,0x00002aaabd692e50,0x00002aaacb760000)
  12. PSPermGen total 131072K, used 62813K [0x00002aaaae200000, 0x00002aaab6200000, 0x00002aaab6200000)
  13. object space 131072K, 47% used [0x00002aaaae200000,0x00002aaab1f57670,0x00002aaab6200000)

分析3上,从上面的日志可以肯定是Young GC的时候发生了异常,导致JVM crash。

在网上查询这个异常,发现很多人碰到了这个问题然后看到sun jdk 官网上,这个版本(1.6_18有已知的问题,其中一条讲的就是我们的问题:

引用代码 收藏代码
  1. Card-Marking Optimization Issue
  2. • A flaw in the implementation of a card-marking performance optimization in the JVM can cause heap corruption under some circumstances. This issue affects the CMS garbage collector prior to 6u18, and the CMS, G1 and Parallel Garbage Collectors in 6u18. The serial garbage collector is not affected. Applications most likely to be affected by this issue are those that allocate very large objects which would not normally fit in Eden, or those that make extensive use of JNI Critical Sections (JNI Get/Release*Critical).
  3. This issue will be fixed in the next Java SE 6 update.
  4. Meanwhile, as a workaround to the issue, users should disable this performance optimization by -XX:-ReduceInitialCardMarks.

解决方案:通过jdk 增加这个 -XX:-ReduceInitialCardMarks 项,避免这个问题。

总结:

JVM crash时,充分分析JVM自动生成的hs_err_pid.log文件;如果确定是JVM的问题后,去网上google,并且上Sun的官网。

[@more@]

目前正在根据这篇文章进行客户问题的处理。

重点是如何根据出错的日志分析出来GC的问题。后续的跟进才是重点。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/8304426/viewspace-1054170/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/8304426/viewspace-1054170/

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值