A fatal error has been detected by the Java Runtime Environment程序错误处理方法

时间:2021-04-17 17:07:15
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x70e72b89, pid=8020, tid=7880
#
# JRE version: Java(TM) SE Runtime Environment (7.0_79-b15) (build 1.7.0_79-b15)
# Java VM: Java HotSpot(TM) Client VM (24.79-b02 mixed mode, sharing windows-x86 )
# Problematic frame:
# V [jvm.dll+0xc2b89]
#
# 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.java.com/bugreport/crash.jsp
#

一般地,这类错误是自编函数出错导致的系统错误的。与JAVA平台无关。根据错误日志文件,我们可以查看出错的具体原因。

下面代码片段是一次错误生成的日志文件:

Stack: [0x005c0000,0x00610000],  sp=0x0060ef80,  free space=315k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [jvm.dll+0xc2b89]
C [split_sentence_jni.dll+0x15c1]
j edu.hit.ir.ltp4j.SplitSentence.splitSentence(Ljava/lang/String;Ljava/util/List;)V+0
j com.Controller.NLP.preprocessor.NLPfun.splitSentence(Ljava/lang/String;)Ljava/util/List;+10
j com.Controller.NLP.preprocessor.test_NLPProcessor.NLP()V+61
v ~StubRoutines::call_stub
V [jvm.dll+0x14234a]
V [jvm.dll+0x206ebe]
V [jvm.dll+0x1423cd]
V [jvm.dll+0x14e6be]
V [jvm.dll+0x14e8e5]
V [jvm.dll+0xf2ec9]
C [java.dll+0x7d8b]
根据这个文件,我们可以清楚地看到这个错误是因为使用动态库split_sentence_jni.dll导致的,但是,错误的发生不是因为动态库split_sentence_jni.dll有问题,而是在使用相关函数时出错,例如:

List<String> sents = NLPfun.splitSentence(content);
在使用上述函数时,将null赋值给了content,导致程序运行出错!

同理,下述错误是由于句法分析函数接受了过长的句子的输入,导致句法分析出错,这个错误是parser.dll本身的错误。为了避免错误的发生,parser处理函数的输入句子最好小于200.

Stack: [0x00940000,0x00990000],  sp=0x0098efb0,  free space=315k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [KERNELBASE.dll+0xb727]
C [msvcr100.dll+0x2872d]
C [msvcr100.dll+0x3f30f]
C [parser.dll+0xffa0]
C [parser.dll+0x10ec5]
C [parser.dll+0x4555]
C [parser.dll+0x4704]
C [parser_jni.dll+0x1d90]
j edu.hit.ir.ltp4j.Parser.parse(Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;)I+0