使用GDAL造成 A fatal error has been detected by the Java Runtime Environment 程序错误处理方法

  • Post author:
  • Post category:java


#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000005c4b2930, pid=11432, tid=0x0000000000004684
#
# JRE version: Java(TM) SE Runtime Environment (8.0_144-b01) (build 1.8.0_144-b01)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.144-b01 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [gdal202.dll+0xbb2930]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\workplace\workspace-ODN\pdnms-project\hs_err_pid11432.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#


[error occurred during error reporting , id 0xc0000005]

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

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

Stack: [0x000000007a890000,0x000000007a990000],  sp=0x000000007a98ec38,  free space=1019k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [gdal202.dll+0xbb2930]


Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J 41252  org.gdal.gdal.gdalJNI.delete_Dataset(J)V (0 bytes) @ 0x0000000008261641 [0x0000000008261600+0x41]
J 41251 C1 org.gdal.gdal.Dataset.delete()V (38 bytes) @ 0x0000000008261b54 [0x0000000008261980+0x1d4]
j  autocad.tiff.TiffDomain.combineTiles([DLautocad/tiff/TilesBound;Ljava/lang/String;Ljava/lang/String;Lpubsub/dto/PubSubDto;)V+389
j  autocad.tiff.TiffDomain.export(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IL/pubsub/dto/PubSubDto;)V+216
j  autocad.service.AutocadServiceImpl$1.run()V+181
v  ~StubRoutines::call_stub


---------------  P R O C E S S  ---------------


根据这个文件,我们可以清楚地看到这个错误是因为使用动态库

gdal202.dll

导致的,但是,错误的发生不是因为动态库

gdal202.dll

有问题,而是在使用相关函数时出错,如下:

final Driver driver = gdal.GetDriverByName("GTiff");
final Vector meta = driver.GetMetadata_List();final Dataset dest = driver.Create(outPutFileName, imageWidth, imageHeight, 3, gdalconst.GDT_Byte, meta);
dest.SetGeoTransform(geoTransform);

...

dest.FlushCache();
dest.delete();//报错位置
driver.delete();
致使

下图,this.swigCPtr=0 bytes,导致程序运行出错!




版权声明:本文为u014182690原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。