File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other JSE/JEE APIs and the fly likes Java application crashes due to some problem in native  code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Java application crashes due to some problem in native  code " Watch "Java application crashes due to some problem in native  code " New topic
Author

Java application crashes due to some problem in native code

krischk jaco
Greenhorn

Joined: May 14, 2008
Posts: 3
Hi All

I have a Java application that calls APIs in a 3rd party DLL(I don't have access to its source code or logs) through my VC++ DLL(Win32) that acts as the wrapper DLL.

The Application has many functionalities and is based on multithreading (both on Java layer as well as C++ layer). Most of the functionalities are working , but when I try to close the application, it crashes.

Moreover the crashing occurs inconstently, sometimes it does not crash. Instead of showing any debug information , it simply creates a error file with disassembly code that I am not able to understand.

Though the error seems like an java error, but actually it seems to be due to native code. I have try catch blocks in my code and also implemented _set_translator functionality to get hold of structured/C exceptions. But still I am not able to catch any exceptions.


I am pasting the the contents of the file here:

#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7c9111de, pid=488, tid=1848
#
# Java VM: Java HotSpot(TM) Client VM (1.4.2_14-b05 mixed mode)
# Problematic frame:
# C [ntdll.dll+0x111de]
#

--------------- T H R E A D ---------------

Current thread (0x009d1790): JavaThread "CompilerThread0" daemon [_thread_in_native, id=1848]

siginfo: ExceptionCode=0xc0000005, reading address 0x00000001

Registers:
EAX=0x00000001, EBX=0x00030000, ECX=0x02d17a18, EDX=0x00030278
ESP=0x02c2f8e8, EBP=0x02c2fb08, ESI=0x02d17a10, EDI=0x00000001
EIP=0x7c9111de, EFLAGS=0x00010202

Top of Stack: (sp=0x02c2f8e8)
0x02c2f8e8: 009fa9a0 000000c0 00000008 0811d3d8
0x02c2f8f8: 0000000c 00a2c0e0 00000003 00000004
0x02c2f908: 08018216 00000001 02c2fcc4 08018385
0x02c2f918: 00000002 00000001 02c2f93c 02d06d0c
0x02c2f928: 0802a50a 00000000 00000001 02c2f93c
0x02c2f938: 04a3cb4c 02d01008 02c2f964 0802a850
0x02c2f948: 02c2f96e 00000000 00000007 00000000
0x02c2f958: 04a3cb38 00000004 08018216 00000001

Instructions: (pc=0x7c9111de)
0x7c9111ce: 39 89 bd 0c ff ff ff 8b 46 0c 89 85 68 ff ff ff
0x7c9111de: 8b 10 3b 57 04 0f 85 8c 31 02 00 3b d1 0f 85 84


Stack: [0x02bf0000,0x02c30000), sp=0x02c2f8e8, free space=254k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [ntdll.dll+0x111de]
C [MSVCRT.dll+0x1c3c9]
C [MSVCRT.dll+0x1c3e7]
C [MSVCRT.dll+0x1c42e]
V [jvm.dll+0xacda9]
V [jvm.dll+0x17102]
V [jvm.dll+0x16c8d]
V [jvm.dll+0x16dca]
V [jvm.dll+0x170a7]
V [jvm.dll+0x172e8]
V [jvm.dll+0x4dc65]
V [jvm.dll+0x4d894]
V [jvm.dll+0xd3a36]
V [jvm.dll+0xd3a04]
C [MSVCRT.dll+0x2a3b0]
C [kernel32.dll+0xb683]


Current CompileTask:
HotSpot Client Compiler:423 b sun.awt.AWTAutoShutdown.isReadyToShutdown()Z (33 bytes)


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

Java Threads: ( => current thread )
0x049d6328 JavaThread "Thread-19" [_thread_blocked, id=1440]
0x049d24d0 JavaThread "Thread-18" [_thread_blocked, id=3620]
0x049d40c8 JavaThread "Thread-17" [_thread_blocked, id=2476]
0x02df0538 JavaThread "TimerQueue" daemon [_thread_blocked, id=3876]
0x00036a78 JavaThread "DestroyJavaVM" [_thread_blocked, id=2448]
0x02e43768 JavaThread "Thread-6" [_thread_blocked, id=3664]
0x02e23130 JavaThread "Thread-4" [_thread_blocked, id=2816]
0x02e21d08 JavaThread "Thread-2" [_thread_blocked, id=3344]
0x02da3f78 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=2528]
0x02da3268 JavaThread "AWT-EventQueue-0" [_thread_in_native, id=4008]
0x02d91f90 JavaThread "AWT-Windows" daemon [_thread_blocked, id=648]
0x02d3a478 JavaThread "AWT-Shutdown" [_thread_blocked, id=2988]
=>0x009d1790 JavaThread "CompilerThread0" daemon [_thread_in_native, id=1848]
0x009d0a90 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=3568]
0x009ce128 JavaThread "Finalizer" daemon [_thread_blocked, id=1824]
0x009ccda0 JavaThread "Reference Handler" daemon [_thread_blocked, id=3280]

Other Threads:
0x00a0b6e8 VMThread [id=608]
0x00a0d620 WatcherThread [id=3012]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
def new generation total 640K, used 583K [0x10010000, 0x100c0000, 0x104f0000)
eden space 576K, 90% used [0x10010000, 0x10091e40, 0x100a0000)
from space 64K, 99% used [0x100b0000, 0x100bfff8, 0x100c0000)
to space 64K, 0% used [0x100a0000, 0x100a0000, 0x100b0000)
tenured generation total 7772K, used 5451K [0x104f0000, 0x10c87000, 0x14010000)
the space 7772K, 70% used [0x104f0000, 0x10a42d80, 0x10a42e00, 0x10c87000)
compacting perm gen total 8192K, used 8137K [0x14010000, 0x14810000, 0x18010000)
the space 8192K, 99% used [0x14010000, 0x148024e8, 0x14802600, 0x14810000)

Dynamic libraries:
0x00400000 - 0x0040b000 c:\dcsthick\jre\bin\java.exe
0x7c900000 - 0x7c9b0000 C:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c8f5000 C:\WINDOWS\system32\kernel32.dll
0x77dd0000 - 0x77e6b000 C:\WINDOWS\system32\ADVAPI32.dll
0x77e70000 - 0x77f01000 C:\WINDOWS\system32\RPCRT4.dll
0x77c10000 - 0x77c68000 C:\WINDOWS\system32\MSVCRT.dll
0x08000000 - 0x08143000 c:\dcsthick\jre\bin\client\jvm.dll
0x7e410000 - 0x7e4a1000 C:\WINDOWS\system32\USER32.dll
0x77f10000 - 0x77f57000 C:\WINDOWS\system32\GDI32.dll
0x76b40000 - 0x76b6d000 C:\WINDOWS\system32\WINMM.dll
0x76390000 - 0x763ad000 C:\WINDOWS\system32\IMM32.DLL
0x10000000 - 0x10007000 c:\dcsthick\jre\bin\hpi.dll
0x76bf0000 - 0x76bfb000 C:\WINDOWS\system32\PSAPI.DLL
0x00390000 - 0x0039e000 c:\dcsthick\jre\bin\verify.dll
0x003b0000 - 0x003c9000 c:\dcsthick\jre\bin\java.dll
0x003d0000 - 0x003de000 c:\dcsthick\jre\bin\zip.dll
0x02e70000 - 0x02f84000 C:\dcsthick\jre\bin\awt.dll
0x73000000 - 0x73026000 C:\WINDOWS\system32\WINSPOOL.DRV
0x774e0000 - 0x7761d000 C:\WINDOWS\system32\ole32.dll
0x5ad70000 - 0x5ada8000 C:\WINDOWS\SYSTEM32\uxtheme.dll
0x02fe0000 - 0x03031000 C:\dcsthick\jre\bin\fontmanager.dll
0x73760000 - 0x737a9000 C:\WINDOWS\system32\ddraw.dll
0x73bc0000 - 0x73bc6000 C:\WINDOWS\system32\DCIMAN32.dll
0x73940000 - 0x73a10000 C:\WINDOWS\system32\D3DIM700.DLL
0x74720000 - 0x7476b000 C:\WINDOWS\system32\MSCTF.dll
0x755c0000 - 0x755ee000 C:\WINDOWS\system32\msctfime.ime
0x03320000 - 0x0333c000 C:\dcsthick\lib\CrewsDmApiJniNt.dll
0x031b0000 - 0x031bb000 c:\dcsthick\lib\CRWNT_DM.dll
0x03240000 - 0x03249000 c:\dcsthick\lib\BAT_API.dll
0x03340000 - 0x03352000 c:\dcsthick\lib\DC_DSM32.dll
0x03360000 - 0x03369000 c:\dcsthick\lib\CRWTOOLS.dll
0x77c00000 - 0x77c08000 C:\WINDOWS\system32\VERSION.dll
0x03370000 - 0x0337a000 c:\dcsthick\lib\PMAPI.dll
0x5d090000 - 0x5d12a000 C:\WINDOWS\system32\COMCTL32.dll
0x03790000 - 0x037b2000 c:\dcsthick\ResaDLL\DC_DSMNB.dll
0x5b860000 - 0x5b8b4000 C:\WINDOWS\system32\NETAPI32.dll
0x038d0000 - 0x038f2000 c:\dcsthick\ResaDLL\DC_DSMIP.dll
0x71ad0000 - 0x71ad9000 C:\WINDOWS\system32\WSOCK32.dll
0x71ab0000 - 0x71ac7000 C:\WINDOWS\system32\WS2_32.dll
0x71aa0000 - 0x71aa8000 C:\WINDOWS\system32\WS2HELP.dll
0x71a50000 - 0x71a8f000 C:\WINDOWS\system32\mswsock.dll
0x662b0000 - 0x66308000 C:\WINDOWS\system32\hnetcfg.dll
0x71a90000 - 0x71a98000 C:\WINDOWS\System32\wshtcpip.dll
0x76f20000 - 0x76f47000 C:\WINDOWS\system32\DNSAPI.dll
0x76fb0000 - 0x76fb8000 C:\WINDOWS\System32\winrnr.dll
0x76f60000 - 0x76f8c000 C:\WINDOWS\system32\WLDAP32.dll
0x66580000 - 0x6658f000 C:\WINDOWS\system32\pnrpnsp.dll
0x76fc0000 - 0x76fc6000 C:\WINDOWS\system32\rasadhlp.dll
0x032e0000 - 0x0330a000 C:\dcsthick\lib\ResaHostConnection.dll
0x03250000 - 0x03257000 c:\dcsthick\lib\CRWNT_GWALC.dll
0x03310000 - 0x03319000 c:\dcsthick\lib\ALCAPI.dll
0x763b0000 - 0x763f9000 C:\WINDOWS\system32\comdlg32.dll
0x77f60000 - 0x77fd6000 C:\WINDOWS\system32\SHLWAPI.dll
0x7c9c0000 - 0x7d1d7000 C:\WINDOWS\system32\SHELL32.dll
0x773d0000 - 0x774d3000 C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2982_x-ww_ac3f9c03\comctl32.dll

VM Arguments:
jvm_args: -Dcfdynaproppath=c:\dcsthick/config/ -Dcfdynapropxml=RESA_KCOdynamicproperties.xml -DConfigPath=c:\dcsthick/config/RESA_KCOConfig.xml -DResolution=High -DWorkstationID=GWGTE -DMode=GateBoarding -DlogPath=c:\temp\kcologs -DlogInformation=0 -DGateway=ALCSQ1 -DNetBiosPort=A
java_command: com.singaporeair.dcs.standalone.application.model.ApplicationModel SQ/IGATEADXX
Launcher Type: SUN_STANDARD

Environment Variables:
JAVA_HOME=c:\dcsthick\jre\bin
PATH=c:\dcsthick\jre\bin;c:\dcsthick/lib;c:\dcsthick/ResaDLL
USERNAME=USER
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 13, GenuineIntel


--------------- S Y S T E M ---------------

OS: Windows XP Build 2600 Service Pack 2

CPU:total 2 family 6, cmov, cx8, fxsr, mmx, sse, sse2

Memory: 4k page, physical 1039600k(565656k free), swap 2501208k(2091128k free)

vm_info: Java HotSpot(TM) Client VM (1.4.2_14-b05) for windows-x86, built on Mar 14 2007 16:46:11 by "java_re" with MS VC++ 6.0





The JAVA Application during initialisation establishes a connection with the host server for various devices. For each of the device it establishes a separate connection and keeps listening on these connections using multithreading.



During App close, we need to close each of these connections one by one for each device.



The opening /closing of connection is done by 3rd party DLL and call to there APIs is done through a C++ Wrapper DLL that I have built between the Java layer and their DLL.



When we close the Application, I am always able to close the connections on the first 2 devices. Then all of a sudden it crashes either for the 3rd device conn. close or for the 4th one. The code is the same for all the devices . That too sometimes it just goes fine without crashing. If its a null pointer exception, why is it that it crashes on some occassions and not in other times. More importantly, why is it that it does not fail for the first 2 devices , but fails for the 3rd or 4th device connection close?

Can please anyone help me. Please suggest me as to how I can determine the cause of the error.
Thanks in advance.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18709
    
  40

There are no details to prove that the crash dump is caused by threads. In fact, it is likely to be caused by the JNI code. As such, I am moving this topic to the "Other APIs forum".

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

An EXCEPTION_ACCESS_VIOLATION is usually caused by a "NullPointerException" in native code, or by trying to read from a memory address that has already been freed.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java application crashes due to some problem in native code