概述
做JCE的项目,需要为客户提供可连接密码机的第三方安全提供者包。
原先公司是用C库连接密码机,先要求提供JCE的支持,需要用到JNI来改造C库。
有现成的JNI调用。但是具体的实现类没有加包名,在JCE的替他类中就无法调用,加包名会出现JVM崩溃错误。先将各种错误记录如下:
1.无包名连接加密卡运行结果:
[img]http://dl.iteye.com/upload/attachment/478647/b9b611ae-8db0-35d1-b4ef-d637cc7ef6ea.jpg[/img]
[color=red]运行到其他相关函数时JVM崩溃。生成hs_err_pid3848.log 日志,内容入下:[/color]
#
# An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7c930ef4, pid=3848, tid=3992
#
# Java VM: Java HotSpot(TM) Client VM (11.0-b15 mixed mode, sharing windows-x86)
# Problematic frame:
# C [ntdll.dll+0x10ef4]
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
--------------- T H R E A D ---------------
Current thread (0x00846c00): JavaThread "main" [_thread_in_vm, id=3992, stack(0x008e0000,0x00930000)]
siginfo: ExceptionCode=0xc0000005, reading address 0xfffffff8
Registers:
EAX=0x00000000, EBX=0x00840000, ECX=0x00000000, EDX=0x00000000
ESP=0x0092f524, EBP=0x0092f744, ESI=0xfffffff8, EDI=0x00000003
EIP=0x7c930ef4, EFLAGS=0x00010206
Top of Stack: (sp=0x0092f524)
0x0092f524: 0000000c 0000000c 00000000 00000000
0x0092f534: 0092f568 00840000 7c930222 00000005
0x0092f544: 0092f578 00840000 7c930222 00000006
0x0092f554: 0092f588 00840000 7c930222 00000007
0x0092f564: 008407d8 00840000 02b22b90 0092f560
0x0092f574: ffffffff 0092f7a4 7c92e920 7c930228
0x0092f584: ffffffff 7c930222 7c93019b 7c9301db
0x0092f594: 0000002c 0000002c 0000002c 00000000
Instructions: (pc=0x7c930ef4)
0x7c930ee4: 94 39 45 d8 0f 84 3e 0a 00 00 8d 70 f8 89 75 c8
0x7c930ef4: 0f b7 0e 3b cf 72 e5 56 ff 75 e4 e8 80 f7 ff ff
Stack: [0x008e0000,0x00930000], sp=0x0092f524, free space=317k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [ntdll.dll+0x10ef4]
C [msvcr71.dll+0x16b3]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j SkyJavaAPI.RsaEncrypt_Ex(I[BI[B[I)I+0
j JavaTest.SkyOtherTest()V+280
j JavaTest.main([Ljava/lang/String;)V+37
v ~StubRoutines::call_stub
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x02b11400 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=3580, stack(0x02d80000,0x02dd0000)]
0x02b0c400 JavaThread "CompilerThread0" daemon [_thread_blocked, id=3904, stack(0x02d30000,0x02d80000)]
0x02b07800 JavaThread "Attach Listener" daemon [_thread_blocked, id=2716, stack(0x02ce0000,0x02d30000)]
0x02b06800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=2848, stack(0x02c90000,0x02ce0000)]
0x02ac0800 JavaThread "Finalizer" daemon [_thread_blocked, id=2980, stack(0x02c40000,0x02c90000)]
0x02abf000 JavaThread "Reference Handler" daemon [_thread_blocked, id=2996, stack(0x02bf0000,0x02c40000)]
=>0x00846c00 JavaThread "main" [_thread_in_vm, id=3992, stack(0x008e0000,0x00930000)]
Other Threads:
0x02abd800 VMThread [stack: 0x02ba0000,0x02bf0000] [id=2140]
0x02b13c00 WatcherThread [stack: 0x02dd0000,0x02e20000] [id=2296]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: ([mutex/lock_event])
[0x008451b8] UNKNOWN - owner thread: 0x00846c00
Heap
def new generation total 960K, used 538K [0x229e0000, 0x22ae0000, 0x22ec0000)
eden space 896K, 60% used [0x229e0000, 0x22a66a00, 0x22ac0000)
from space 64K, 0% used [0x22ac0000, 0x22ac0000, 0x22ad0000)
to space 64K, 0% used [0x22ad0000, 0x22ad0000, 0x22ae0000)
tenured generation total 4096K, used 0K [0x22ec0000, 0x232c0000, 0x269e0000)
the space 4096K, 0% used [0x22ec0000, 0x22ec0000, 0x22ec0200, 0x232c0000)
compacting perm gen total 12288K, used 388K [0x269e0000, 0x275e0000, 0x2a9e0000)
the space 12288K, 3% used [0x269e0000, 0x26a41358, 0x26a41400, 0x275e0000)
ro space 8192K, 67% used [0x2a9e0000, 0x2af42f30, 0x2af43000, 0x2b1e0000)
rw space 12288K, 53% used [0x2b1e0000, 0x2b850180, 0x2b850200, 0x2bde0000)
Dynamic libraries:
0x00400000 - 0x00424000 C:Program FilesJavajdk1.6.0_10binjavaw.exe
0x7c920000 - 0x7c9b6000 C:WINDOWSsystem32ntdll.dll
0x7c800000 - 0x7c91e000 C:WINDOWSsystem32kernel32.dll
0x77da0000 - 0x77e49000 C:WINDOWSsystem32ADVAPI32.dll
0x77e50000 - 0x77ee2000 C:WINDOWSsystem32RPCRT4.dll
0x77fc0000 - 0x77fd1000 C:WINDOWSsystem32Secur32.dll
0x77d10000 - 0x77da0000 C:WINDOWSsystem32USER32.dll
0x77ef0000 - 0x77f39000 C:WINDOWSsystem32GDI32.dll
0x76300000 - 0x7631d000 C:WINDOWSsystem32IMM32.DLL
0x62c20000 - 0x62c29000 C:WINDOWSsystem32LPK.DLL
0x73fa0000 - 0x7400b000 C:WINDOWSsystem32USP10.dll
0x7c340000 - 0x7c396000 C:Program FilesJavajdk1.6.0_10jrebinmsvcr71.dll
0x6d8b0000 - 0x6db06000 C:Program FilesJavajdk1.6.0_10jrebinclientjvm.dll
0x76b10000 - 0x76b3a000 C:WINDOWSsystem32WINMM.dll
0x6d330000 - 0x6d338000 C:Program FilesJavajdk1.6.0_10jrebinhpi.dll
0x76bc0000 - 0x76bcb000 C:WINDOWSsystem32PSAPI.DLL
0x6d860000 - 0x6d86c000 C:Program FilesJavajdk1.6.0_10jrebinverify.dll
0x6d3d0000 - 0x6d3ef000 C:Program FilesJavajdk1.6.0_10jrebinjava.dll
0x6d8a0000 - 0x6d8af000 C:Program FilesJavajdk1.6.0_10jrebinzip.dll
0x10000000 - 0x10042000 C:WINDOWSsystem32SkyJavaAPI.dll
0x02e20000 - 0x02e44000 C:WINDOWSsystem32SkyEnCard.dll
0x76060000 - 0x761b6000 C:WINDOWSsystem32SETUPAPI.dll
0x77be0000 - 0x77c38000 C:WINDOWSsystem32msvcrt.dll
VM Arguments:
jvm_args: -Xbootclasspath:C:Program FilesJavajdk1.6.0_10jrelibresources.jar;C:Program FilesJavajdk1.6.0_10jrelibrt.jar;C:Program FilesJavajdk1.6.0_10jrelibjsse.jar;C:Program FilesJavajdk1.6.0_10jrelibjce.jar;C:Program FilesJavajdk1.6.0_10jrelibcharsets.jar
java_command: JavaTest
Launcher Type: SUN_STANDARD
Environment Variables:
JAVA_HOME=C:Program FilesJavajdk1.6.0_10
CLASSPATH=.;C:Program FilesJavajdk1.6.0_10lib;
PATH=C:Program FilesJavajdk1.6.0_10bin;C:MinGWbin;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;
USERNAME=Administrator
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 37 Stepping 2, GenuineIntel
--------------- S Y S T E M ---------------
OS: Windows XP Build 2600 Service Pack 3
CPU:total 4 (8 cores per cpu, 2 threads per core) family 6 model 5 stepping 2, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, ht
Memory: 4k page, physical 2022444k(773880k free), swap 3961040k(2317836k free)
vm_info: Java HotSpot(TM) Client VM (11.0-b15) for windows-x86 JRE (1.6.0_10-rc2-b32), built on Sep 12 2008 00:52:11 by "java_re" with MS VC++ 7.1
time: Tue May 10 14:22:43 2011
elapsed time: 0 seconds
[color=red]二.因为要调用上面测试类具体方法,需要为其加包名。重新生成带包名的.h头文件,并在C库的具体实现中改变函数名,生成新的dll文件。运行结果如下:[/color]
[img]http://dl.iteye.com/upload/attachment/478649/c3c0cc14-3810-39ac-8a4f-6bc268bbaa87.jpg[/img]
[color=red]在设备管理类函数中 JVM崩溃,错误日志hs_err_pid3480.log如下:#[/color]
# An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d98af60, pid=3480, tid=1940
#
# Java VM: Java HotSpot(TM) Client VM (11.0-b15 mixed mode, sharing windows-x86)
# Problematic frame:
# V [jvm.dll+0xdaf60]
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
--------------- T H R E A D ---------------
Current thread (0x00846c00): JavaThread "main" [_thread_in_vm, id=1940, stack(0x008e0000,0x00930000)]
siginfo: ExceptionCode=0xc0000005, reading address 0x00000000
Registers:
EAX=0x00000000, EBX=0x00847318, ECX=0x008467c8, EDX=0x00847320
ESP=0x0092fab8, EBP=0x00846c00, ESI=0x2adb99e8, EDI=0x0084731c
EIP=0x6d98af60, EFLAGS=0x00010202
Top of Stack: (sp=0x0092fab8)
0x0092fab8: 0092fb5c 0092fb0c 0092fb5c 26a3df50
0x0092fac8: 00846c00 00847314 000000b7 6daa9af8
0x0092fad8: 26a3df50 0092fb18 00846c00 00847318
0x0092fae8: 00846c00 00000000 02e32c08 02e60000
0x0092faf8: 1000197a 00846c00 00000000 10031190
0x0092fb08: 100311a0 0092fc48 26a3df50 26a3df50
0x0092fb18: cccccccc cccccccc cccccccc cccccccc
0x0092fb28: cccccccc cccccccc cccccccc cccccccc
Instructions: (pc=0x6d98af60)
0x6d98af50: f5 00 00 00 85 ff 0f 84 ed 00 00 00 8b 44 24 48
0x6d98af60: 8b 00 50 e8 58 ee fe ff 83 c4 04 50 55 8d 4c 24
Stack: [0x008e0000,0x00930000], sp=0x0092fab8, free space=318k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [jvm.dll+0xdaf60]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j com.skynet.api.SkyJavaAPI.GetDeviceInfo(I)Lcom/skynet/api/DEVICEINFO;+0
j com.skynet.api.JavaTest.DeviceTest()V+91
j com.skynet.api.JavaTest.main([Ljava/lang/String;)V+13
v ~StubRoutines::call_stub
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x02b11c00 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=2956, stack(0x02d80000,0x02dd0000)]
0x02b0c400 JavaThread "CompilerThread0" daemon [_thread_blocked, id=3572, stack(0x02d30000,0x02d80000)]
0x02b07800 JavaThread "Attach Listener" daemon [_thread_blocked, id=2440, stack(0x02ce0000,0x02d30000)]
0x02b06800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=3524, stack(0x02c90000,0x02ce0000)]
0x02ac3c00 JavaThread "Finalizer" daemon [_thread_blocked, id=3212, stack(0x02c40000,0x02c90000)]
0x02abf000 JavaThread "Reference Handler" daemon [_thread_blocked, id=3692, stack(0x02bf0000,0x02c40000)]
=>0x00846c00 JavaThread "main" [_thread_in_vm, id=1940, stack(0x008e0000,0x00930000)]
Other Threads:
0x02abd800 VMThread [stack: 0x02ba0000,0x02bf0000] [id=3776]
0x02b13c00 WatcherThread [stack: 0x02dd0000,0x02e20000] [id=2776]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
Heap
def new generation total 960K, used 677K [0x229e0000, 0x22ae0000, 0x22ec0000)
eden space 896K, 75% used [0x229e0000, 0x22a896b0, 0x22ac0000)
from space 64K, 0% used [0x22ac0000, 0x22ac0000, 0x22ad0000)
to space 64K, 0% used [0x22ad0000, 0x22ad0000, 0x22ae0000)
tenured generation total 4096K, used 0K [0x22ec0000, 0x232c0000, 0x269e0000)
the space 4096K, 0% used [0x22ec0000, 0x22ec0000, 0x22ec0200, 0x232c0000)
compacting perm gen total 12288K, used 432K [0x269e0000, 0x275e0000, 0x2a9e0000)
the space 12288K, 3% used [0x269e0000, 0x26a4c280, 0x26a4c400, 0x275e0000)
ro space 8192K, 67% used [0x2a9e0000, 0x2af42f30, 0x2af43000, 0x2b1e0000)
rw space 12288K, 53% used [0x2b1e0000, 0x2b850180, 0x2b850200, 0x2bde0000)
Dynamic libraries:
0x00400000 - 0x00424000 C:Program FilesJavajdk1.6.0_10binjavaw.exe
0x7c920000 - 0x7c9b6000 C:WINDOWSsystem32ntdll.dll
0x7c800000 - 0x7c91e000 C:WINDOWSsystem32kernel32.dll
0x77da0000 - 0x77e49000 C:WINDOWSsystem32ADVAPI32.dll
0x77e50000 - 0x77ee2000 C:WINDOWSsystem32RPCRT4.dll
0x77fc0000 - 0x77fd1000 C:WINDOWSsystem32Secur32.dll
0x77d10000 - 0x77da0000 C:WINDOWSsystem32USER32.dll
0x77ef0000 - 0x77f39000 C:WINDOWSsystem32GDI32.dll
0x76300000 - 0x7631d000 C:WINDOWSsystem32IMM32.DLL
0x62c20000 - 0x62c29000 C:WINDOWSsystem32LPK.DLL
0x73fa0000 - 0x7400b000 C:WINDOWSsystem32USP10.dll
0x7c340000 - 0x7c396000 C:Program FilesJavajdk1.6.0_10jrebinmsvcr71.dll
0x6d8b0000 - 0x6db06000 C:Program FilesJavajdk1.6.0_10jrebinclientjvm.dll
0x76b10000 - 0x76b3a000 C:WINDOWSsystem32WINMM.dll
0x6d330000 - 0x6d338000 C:Program FilesJavajdk1.6.0_10jrebinhpi.dll
0x76bc0000 - 0x76bcb000 C:WINDOWSsystem32PSAPI.DLL
0x6d860000 - 0x6d86c000 C:Program FilesJavajdk1.6.0_10jrebinverify.dll
0x6d3d0000 - 0x6d3ef000 C:Program FilesJavajdk1.6.0_10jrebinjava.dll
0x6d8a0000 - 0x6d8af000 C:Program FilesJavajdk1.6.0_10jrebinzip.dll
0x10000000 - 0x10042000 C:WINDOWSsystem32SkyJavaAPI.dll
0x02e20000 - 0x02e44000 C:WINDOWSsystem32SkyEnCard.dll
0x76060000 - 0x761b6000 C:WINDOWSsystem32SETUPAPI.dll
0x77be0000 - 0x77c38000 C:WINDOWSsystem32msvcrt.dll
VM Arguments:
jvm_args: -Xbootclasspath:C:Program FilesJavajdk1.6.0_10jrelibresources.jar;C:Program FilesJavajdk1.6.0_10jrelibrt.jar;C:Program FilesJavajdk1.6.0_10jrelibjsse.jar;C:Program FilesJavajdk1.6.0_10jrelibjce.jar;C:Program FilesJavajdk1.6.0_10jrelibcharsets.jar
java_command: com.skynet.api.JavaTest
Launcher Type: SUN_STANDARD
Environment Variables:
JAVA_HOME=C:Program FilesJavajdk1.6.0_10
CLASSPATH=.;C:Program FilesJavajdk1.6.0_10lib;
PATH=C:Program FilesJavajdk1.6.0_10bin;C:MinGWbin;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;
USERNAME=Administrator
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 37 Stepping 2, GenuineIntel
--------------- S Y S T E M ---------------
OS: Windows XP Build 2600 Service Pack 3
CPU:total 4 (8 cores per cpu, 2 threads per core) family 6 model 5 stepping 2, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, ht
Memory: 4k page, physical 2022444k(792388k free), swap 3961040k(2329080k free)
vm_info: Java HotSpot(TM) Client VM (11.0-b15) for windows-x86 JRE (1.6.0_10-rc2-b32), built on Sep 12 2008 00:52:11 by "java_re" with MS VC++ 7.1
time: Tue May 10 14:18:23 2011
elapsed time: 0 seconds
三。现在记录下来寻求解决办法。。。
待续............
最后
以上就是无限河马为你收集整理的通过JNI调C库连接密码卡导致JVM崩溃的记录(一)的全部内容,希望文章能够帮你解决通过JNI调C库连接密码卡导致JVM崩溃的记录(一)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复