本文分三个部分讲解:前提、现象、分析
一、前提:
jdk1.7。tomcat7.access数据库,win7
这里将“前提”列出,是因为:同样的程序,在win10上正常运行,但是在win7中直接就奔溃。
另外的话,各个版本不同,可能不存在这个问题。
二、现象
tomcat在运行过程中突然奔溃、关闭;同时在bin目录下生成日志文件hs_err_pidxxxx.log
三、分析:
由于文件内容较多,这里只给出关键段落的内容分析:
1.开头的错误类型内容如下:
# # A fatal error has been detected by the Java Runtime Environment: # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffb91acb07e, pid=2840, tid=5112 # # JRE version: Java(TM) SE Runtime Environment (7.0_67-b01) (build 1.7.0_67-b01) # Java VM: Java HotSpot(TM) 64-Bit Server VM (24.65-b04 mixed mode windows-amd64 compressed oops) # Problematic frame: # C [mso20win32client.dll+0xeb07e] # # Failed to write core dump. Minidumps are not enabled by default on client versions of Windows # # If you would like to submit a bug report, please visit: # http://bugreport.sun.com/bugreport/crash.jsp # The crash happened outside the Java Virtual Machine in native code. # See problematic frame for where to report the bug. #有两个关键点:
1)错误来源和类型: by the Java Runtime Environment和EXCEPTION_ACCESS_VIOLATION (0xc0000005),表明是Java的问题。
2)错误时执行的库:
Problematic frame: # C [mso20win32client.dll+0xeb07e]
我这里的是C,表明是Native C frame。(可能有的人是V等其他字母,那跳转到文章最后的链接,多半是线程问题)
2.中间错误分析:
Register to memory mapping: RAX=0x000000001f752c50 is an unknown value RBX=0x00007ffb89854fa0 is an unknown value RCX=0x0000000000000035 is an unknown value RDX=0x00007ffb89854fa0 is an unknown value RSP=0x0000000012bfc360 is pointing into the stack for thread: 0x0000000010a2c000 RBP=0x0000000012bfc569 is pointing into the stack for thread: 0x0000000010a2c000 RSI=0x00007ffb89854fa0 is an unknown value RDI=0x000000001f947570 is an unknown value R8 =0x0000000012bfc6a0 is pointing into the stack for thread: 0x0000000010a2c000 R9 =0x0000000012bfc428 is pointing into the stack for thread: 0x0000000010a2c000 R10=0x0000000000000000 is an unknown value R11=0x0000000012bfc3e0 is pointing into the stack for thread: 0x0000000010a2c000 R12=0x0000000000000000 is an unknown value R13=0x00007ffb899d90b8 is an unknown value R14=0x0000000000000002 is an unknown value R15=0x0000000012bfc6a0 is pointing into the stack for thread: 0x0000000010a2c000 Stack: [0x0000000012b00000,0x0000000012c00000], sp=0x0000000012bfc360, free space=1008k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) C [mso20win32client.dll+0xeb07e] Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) j sun.jdbc.odbc.JdbcOdbc.driverConnect(J[B[B)V+0 j sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JLjava/lang/String;)V+93 j sun.jdbc.odbc.JdbcOdbcConnection.initialize(Ljava/lang/String;Ljava/util/Properties;I)V+984 j sun.jdbc.odbc.JdbcOdbcDriver.connect(Ljava/lang/String;Ljava/util/Properties;)Ljava/sql/Connection;+129 j java.sql.DriverManager.getConnection(Ljava/lang/String;Ljava/util/Properties;Ljava/lang/Class;)Ljava/sql/Connection;+172 j java.sql.DriverManager.getConnection(Ljava/lang/String;Ljava/util/Properties;)Ljava/sql/Connection;+5 j deskomc.websocket.omc.DefaultEchoService.getAccessCon()Ljava/sql/Connection;+102 j deskomc.websocket.omc.DefaultEchoService.getMessage(Ljava/lang/String;Lorg/springframework/web/socket/WebSocketSession;)Ljava/lang/String;+31 j deskomc.websocket.omc.OmcWebSocketHandler.handleTextMessage(Lorg/springframework/web/socket/WebSocketSession;Lorg/springframework/web/socket/TextMessage;)V+34 j org.springframework.web.socket.handler.AbstractWebSocketHandler.handleMessage(Lorg/springframework/web/socket/WebSocketSession;Lorg/springframework/web/socket/WebSocketMessage;)V+13 j org.springframework.web.socket.handler.WebSocketHandlerDecorator.handleMessage(Lorg/springframework/web/socket/WebSocketSession;Lorg/springframework/web/socket/WebSocketMessage;)V+6 j org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator.handleMessage(Lorg/springframework/web/socket/WebSocketSession;Lorg/springframework/web/socket/WebSocketMessage;)V+50 j org.springframework.web.socket.handler.ExceptionWebSocketHandlerDecorator.handleMessage(Lorg/springframework/web/socket/WebSocketSession;Lorg/springframework/web/socket/WebSocketMessage;)V+6 j org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.handleTextMessage(Ljavax/websocket/Session;Ljava/lang/String;Z)V+21 j org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.access$00找到错误所在位置分析,我的是DefaultEchoService下的getAccessCon。
注意:最好是让程序奔溃5次以上,综合分析,得出的奔溃节点才准确!比如我上面的getAccessCon方法虽然是奔溃的点,但是错误的原因是其他方法中的getAccessCon调用过多,导致数据库连接数过多引起的,此处的getAccessCon却是正确的。
(还有的说法是access在多线程不稳定,这个大家自行搜索了)
参考链接:
Problematic frame:# V的问题:https://blog.csdn.net/salonzhou/article/details/37932451
Tomcat异常退出分析和解决方法:https://blog.csdn.net/fangqun663775/article/details/53958661
Invalid handle :https://blog.csdn.net/core_star/article/details/6316739
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows。:http://www.voidcn.com/article/p-tduhahfr-rp.html