最近一周左右,网管监控系统经常监控到tomcat异常退出,由于有检测tomcat pid的脚本,所以会自动重启服务器,查询tomcat日志没有报错信息,查询系统message日志,可以看到如下信息。
Dec 15 22:08:07 net-wap3 kernel: java[8299]: segfault at 00000000453caa98 rip 00002aaac4d055bd rsp 00000000453caa80 error 6
然后用nohup strace -p pid &> strace.log &将程序与内核之间传递的信号记录下来,记录下如下信息:
Process 9754 attached - interrupt to quit
futex(0x40b589d0, FUTEX_WAIT, 9762, NULL <unfinished ...>
+++ killed by SIGSEGV +++
可以看到是被11号信号kill的,然后我们需要得到程序退出时的corefile。
编辑/etc/profile将其中的ulimit -S -c 0 > /dev/null 2>&1改成ulimit -S -c unlimited > /dev/null 2>&1,然后source /etc/profile,用ulimit -c查看查看,将程序重启。
然后查看一下重启后的程序的pid,然后cat /proc/pid/limits,其中
Limit Soft Limit Hard Limit Units
Max core file size unlimited unlimited bytes
确定红色地方为unlimited,确保可以输出corefile,然后运行echo "/corefile/core_%p_%s_%t_%e" > /proc/sys/kernel/core_pattern,将corefile输出到/corefile下,%p代表pid,%s代表引起程序退出的信号,%t代表自1970年1月1日0时到程序退出时的秒数,%e代表可执行文件名,如我得到的文件core_29151_11_1387033918_java。
然后用gdb java core_29151_11_1387033918_java和jstack java core_29151_11_1387033918_java分析。
在jstack输出的结果中发现如下信息
- org.apache.jsp._480.mfb.zt.qc._30999750.index_jsp._jspService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) @bci=1680, line=296 (Interpreted frame)
- org.apache.jasper.runtime.HttpJspBase.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) @bci=3, line=70 (Interpreted frame)
- javax.servlet.http.HttpServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse) @bci=30, line=717 (Compiled frame)
- org.apache.jasper.servlet.JspServletWrapper.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, boolean) @bci=320, line=377 (Compiled frame)
- org.apache.jasper.servlet.JspServlet.serviceJspFile(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String, java.lang.Throwable, boolean) @bci=126, line=313 (Compiled frame)
- org.apache.jasper.servlet.JspServlet.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) @bci=347, line=260 (Compiled frame)
- javax.servlet.http.HttpServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse) @bci=30, line=717 (Compiled frame)
- org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse) @bci=376, line=290 (Compiled frame)
- org.apache.catalina.core.ApplicationFilterChain.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse) @bci=101, line=206 (Compiled frame)
- com.wondertek.mobiletv.portal.webapp.filter.XSSServletFilter.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain) @bci=17, line=59 (Compiled frame)
- org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse) @bci=119, line=235 (Compiled frame)
- org.apache.catalina.core.ApplicationFilterChain.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse) @bci=101, line=206 (Compiled frame)
- org.apache.catalina.core.ApplicationDispatcher.invoke(javax.servlet.ServletRequest, javax.servlet.ServletResponse, org.apache.catalina.core.ApplicationDispatcher$State) @bci=393, line=646 (Compiled frame)
- org.apache.catalina.core.ApplicationDispatcher.doInclude(javax.servlet.ServletRequest, javax.servlet.ServletResponse) @bci=260, line=551 (Compiled frame)
- org.apache.catalina.core.ApplicationDispatcher.include(javax.servlet.ServletRequest, javax.servlet.ServletResponse) @bci=55, line=488 (Compiled frame)
- sun.reflect.GeneratedMethodAccessor307.invoke(java.lang.Object, java.lang.Object[]) @bci=48 (Compiled frame)
- sun.reflect.DelegatingMethodAccessorImpl.invoke(java.lang.Object, java.lang.Object[]) @bci=6, line=25 (Compiled frame)
- java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) @bci=161, line=597 (Compiled frame)
- net.bull.javamelody.JspWrapper.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]) @bci=85, line=151 (Compiled frame)
- net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]) @bci=7, line=282 (Compiled frame)
- $Proxy47.include(javax.servlet.ServletRequest, javax.servlet.ServletResponse) @bci=20 (Compiled frame)
- org.apache.jasper.runtime.JspRuntimeLibrary.include(javax.servlet.ServletRequest, javax.servlet.ServletResponse, java.lang.String, javax.servlet.jsp.JspWriter, boolean) @bci=45, line=968 (Interpreted frame)
- org.apache.jsp._480.mfb.zt.qc._30999750.index_jsp._jspService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) @bci=1695, line=299 (Interpreted frame)
- org.apache.jasper.runtime.HttpJspBase.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) @bci=3, line=70 (Interpreted frame)
- javax.servlet.http.HttpServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse) @bci=30, line=717 (Compiled frame)
- org.apache.jasper.servlet.JspServletWrapper.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, boolean) @bci=320, line=377 (Compiled frame)
- org.apache.jasper.servlet.JspServlet.serviceJspFile(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String, java.lang.Throwable, boolean) @bci=126, line=313 (Compiled frame)
- org.apache.jasper.servlet.JspServlet.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) @bci=347, line=260 (Compiled frame)
- javax.servlet.http.HttpServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse) @bci=30, line=717 (Compiled frame)
- org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse) @bci=376, line=290 (Compiled frame)
- org.apache.catalina.core.ApplicationFilterChain.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse) @bci=101, line=206 (Compiled frame)
- com.wondertek.mobiletv.portal.webapp.filter.XSSServletFilter.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain) @bci=17, line=59 (Compiled frame)
- org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse) @bci=119, line=235 (Compiled frame)
- org.apache.catalina.core.ApplicationFilterChain.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse) @bci=101, line=206 (Compiled frame)
- org.apache.catalina.core.ApplicationDispatcher.invoke(javax.servlet.ServletRequest, javax.servlet.ServletResponse, org.apache.catalina.core.ApplicationDispatcher$State) @bci=393, line=646 (Compiled frame)
- org.apache.catalina.core.ApplicationDispatcher.doInclude(javax.servlet.ServletRequest, javax.servlet.ServletResponse) @bci=260, line=551 (Compiled frame)
- org.apache.catalina.core.ApplicationDispatcher.include(javax.servlet.ServletRequest, javax.servlet.ServletResponse) @bci=55, line=488 (Compiled frame)
- sun.reflect.GeneratedMethodAccessor307.invoke(java.lang.Object, java.lang.Object[]) @bci=48 (Compiled frame)
- sun.reflect.DelegatingMethodAccessorImpl.invoke(java.lang.Object, java.lang.Object[]) @bci=6, line=25 (Compiled frame)
- java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) @bci=161, line=597 (Compiled frame)
- net.bull.javamelody.JspWrapper.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]) @bci=85, line=151 (Compiled frame)
- net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]) @bci=7, line=282 (Compiled frame)
- $Proxy47.include(javax.servlet.ServletRequest, javax.servlet.ServletResponse) @bci=20 (Compiled frame)
- org.apache.jasper.runtime.JspRuntimeLibrary.include(javax.servlet.ServletRequest, javax.servlet.ServletResponse, java.lang.String, javax.servlet.jsp.JspWriter, boolean) @bci=45, line=968 (Interpreted frame)
- org.apache.jsp._480.mfb.zt.qc._30999750.index_jsp._jspService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) @bci=1695, line=299 (Interpreted frame)
- org.apache.jasper.runtime.HttpJspBase.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) @bci=3, line=70 (Interpreted frame)
- javax.servlet.http.HttpServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse) @bci=30, line=717 (Compiled frame)
- org.apache.jasper.servlet.JspServletWrapper.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, boolean) @bci=320, line=377 (Compiled frame)
- org.apache.jasper.servlet.JspServlet.serviceJspFile(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String, java.lang.Throwable, boolean) @bci=126, line=313 (Compiled frame)
- org.apache.jasper.servlet.JspServlet.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) @bci=347, line=260 (Compiled frame)
- javax.servlet.http.HttpServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse) @bci=30, line=717 (Compiled frame)
发现程序异常是由于上面的页面中存在循环导致,至此故障恢复。
- 用JDBC编程的执行时错误及其解决大全
用JDBC编程的执行时错误及其解决 用JDBC编程的执行时错误及其解决 源码: .java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlser ...
- gcc编译通过,运行却显示“段错误”的解决方法
第一次在Liunx上(liunx mint 17)使用gcc编译c文件,竟然提示“找不到stdio.h",经过google后发现执行 sudo apt-get install build- ...
- 实战项目中Java heap space错误的解决
部标GPS通讯系统在上线之后,经过不断调试,终于稳定运行一段时间,后来又遇到了Java heap space错误异常!日志如下: 说明系统中有未释放的对象.如何找出这些未释放对象以及监控JVM堆内存, ...
- Java compiler level does not match the version of the installed java project facet错误的解决
因工作的关系,Eclipse开发的Java项目拷来拷去,有时候会报一个很奇怪的错误.明明源码一模一样,为什么项目复制到另一台机器上,就会报“java compiler level does not m ...
- HIVE-执行distribute by时报错的解决过程---之如何分析hive执行的错误并解决
在执行一条HIVE语句的时候报了以下错误,重新检查了所有步骤,重启所有服务,发现没有问题. 但发现一个有趣的事情 1,select sno,sname,sex,sage,sdept from stud ...
- java 执行sql错误 传入的表格格式数据流(TDS)远程过程调用(RPC)协议流不正确。参数 1 (""): 数据类型 0x38 未知
连接数据库时设置:Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE ,ResultSet.CONCUR_R ...
- java.lang.NumberFormatException 错误及解决办法
package com.geelou.test; public class ErrTest { public static void main(String[] args) { String numS ...
- 我的Android进阶之旅------>Android项目运行报java.lang.NoClassDefFoundError错误的解决办法
今天在运行一个Android项目的时候,报了以下错误: D/AndroidRuntime( 3859): Shutting down VM E/AndroidRuntime( 3859): FATAL ...
- java.lang.NumberFormatException错误及解决方法
java.lang.NumberFormatException 一般由Integer.valueOf(String param)或者Integer.parseInt(String param)引起 不 ...
随机推荐
- vscode:解决操作git总让输入用户名及密码问题
只要是使用git操作,不管是同步,拉去,克隆,vscode总让我们输入用户名及密码,是一件很繁琐的事情 我们打开终端,会看到cmd定位在我们仓库位置,我们只要添加:git config --globa ...
- 如何使git忽略某些文件或文件夹
为什么要忽略某些文件或文件夹的变化? git作为一款项目文件变更版本管理软件,其主要功能之一就是追踪项目文件夹内各种文件及文件夹的变更情况.但是,在日常使用中,并非项目文件夹下的所有文件及文件夹变更都 ...
- Ios国际化翻译工具
IOS Translation Tool(IOS国际化翻译工具) 介绍 当IOS项目国际化的时候,手工去翻译每一个字符串是一件非常痛苦的事情.尤其是当项目中存在N多种语言.而且又很难保证,手工翻译的准 ...
- Linux学习总结(一) windos环境vmware安装centos7
一.在这里我先简单介绍下虚拟化技术[即在一台电脑上虚拟出子系统,而且可能需要多台服务器进行工作,一般都是linux系统做服务器或者学习研究之用], 二来我们可以有效利用一台pc的资源模拟出终端远程访问 ...
- 启用 DHCP
#开启DHCP协议 Get-NetIPInterface -Dhcp Disabled|Set-NetIPInterface -Dhcp Enabled #开启本机上所有博通网卡的DHCP Get-W ...
- 一段基于Redis-SortedSet的限流代码
[HttpGet] public async Task<ActionResult<string>> Get() { //限流周期:5秒 int period = 5; //周期 ...
- Selenium应用代码(读取mysql表数据登录)
1. 封装链接数据库的类: import java.sql.ResultSet; import java.sql.Connection; import java.sql.DriverManager; ...
- 【洛谷P2022】有趣的数
有趣的数 题目链接 首先求出1~k中有多少个在k前面的数的个数,若>m,则无解 比如12345,从第一位开始, 1 0~1 共2个 1-0+1 12 10~12共3个 12-10+1 1 ...
- 第20章 USART—串口通讯
本章参考资料:<STM32F76xxx参考手册>USART章节. 学习本章时,配合<STM32F76xxx参考手册>USART章节一起阅读,效果会更佳,特别是涉及到寄存器说明的 ...
- 课时18.h标签和p标签以及hr标签(掌握)
如何在webstorm中利用快捷键创建一个新的html的文件? 同时按下键盘上的ctrl+alt+insert(windows) 同时按下键盘上的ctrl+alt+n(os) h标签系列(header ...