JNI DLL on Windows XP crashes when lots of memory is available.

I'm using the RXTX COMM jar/DLL for Windows XP (replacement for javax.comm API) from:

http://www.rxtx.org/

This uses JNI to talk to the Windows SerialPort/COM devices.

When I use the stock binaries from the developer (built with GCC 2.95), they seem to work in all situations I test them.

For a couple of reasons, I need to rebuild these libraries. I have a MinGW/MSYS environment with the current GCC release (gcc 3.4.2 (mingw-special)) and everything built fine with the provided makefiles.

However, when I run some small tests with the resulting dll's, I seem some really weird behavior when i vary the Xms and Xmx value.I'm using Sun's JVM, 1.5.0_07.

Using the default min/max: 2/64, everything works OK.

But If I use 32/128, I get a JVM crash.

If I set min/max to 128/128, it works.

If I set min/max to 128/129, it crashes.

It's almost as if when there is more memory available, then the JVM puts the DLL is put in a location that maybe is too "far" away. But AFAICT, there is no option to GCC for near/far calls on X86.

In any case, I'm hoping someone has seen something like this before.

Thanks,

Pete

[1201 byte] By [pete.flugstada] at [2007-10-3 2:51:18]
# 1

FYI, here is the crash I get (hs_err_pid####.log)

#

# An unexpected error has been detected by HotSpot Virtual Machine:

#

# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d7d6fec, pid=4972, tid=3956

#

# Java VM: Java HotSpot(TM) Client VM (1.5.0_07-b03 mixed mode)

# Problematic frame:

# V [jvm.dll+0x116fec]

#

T H R E A D

Current thread (0x0fd23458): JavaThread "Thread-5" [_thread_in_vm, id=3956]

siginfo: ExceptionCode=0xc0000005, reading address 0x1034a2d1

Registers:

EAX=0x1034a2d1, EBX=0x0baccac0, ECX=0x0000deab, EDX=0x6d811570

ESP=0x1118f31c, EBP=0x1118f320, ESI=0x00000000, EDI=0x00000000

EIP=0x6d7d6fec, EFLAGS=0x00010246

Top of Stack: (sp=0x1118f31c)

0x1118f31c:0fd23458 1118f390 6d796650 1034a2d1

0x1118f32c:0fd23458 0fd23458 0baccac0 6d746708

0x1118f33c:1034a2d1 0fd23458 0fd23458 6d74e589

0x1118f34c:1034a2d1 0fd23458 0fd23458 00000006

0x1118f35c:0fd23518 0fd23458 0baccac0 00f6826f

0x1118f36c:0fd23518 1034a2d1 1118f374 0baccac0

0x1118f37c:1118f39c 0baccd10 00000000 0baccac0

0x1118f38c:1118f3a0 1118f3bc 00f629fa 0bacccb8

Instructions: (pc=0x6d7d6fec)

0x6d7d6fdc:7c e9 8b c6 5e c9 c3 55 8b ec 8b 45 08 56 33 f6

0x6d7d6fec:80 38 00 74 0f 8d 4d 0a 46 51 50 e8 cf fe ff ff

Stack: [0x11090000,0x11190000), sp=0x1118f31c, free space=1020k

Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)

V [jvm.dll+0x116fec]

V [jvm.dll+0xd6650]

j gnu.io.RXTXCommDriver.<clinit>()V+9

v ~StubRoutines::call_stub

V [jvm.dll+0x86401]

V [jvm.dll+0xdb172]

V [jvm.dll+0x862d2]

V [jvm.dll+0x78dbf]

V [jvm.dll+0x77ca8]

V [jvm.dll+0xa3657]

V [jvm.dll+0x9ca03]

C [java.dll+0x13d8]

j java.lang.Class.forName0(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;+0

j java.lang.Class.forName(Ljava/lang/String;)Ljava/lang/Class;+5

j gnu.io.CommPortIdentifier.<clinit>()V+12

v ~StubRoutines::call_stub

V [jvm.dll+0x86401]

V [jvm.dll+0xdb172]

V [jvm.dll+0x862d2]

V [jvm.dll+0x78dbf]

V [jvm.dll+0x77ca8]

V [jvm.dll+0xc6987]

V [jvm.dll+0xc7624]

V [jvm.dll+0xc750a]

V [jvm.dll+0x81ae1]

j com.foo.serial.SerialConnection.findTargetPort()Lgnu/io/CommPortIdentifier;+13

j com.foo.serial.SerialConnection.run()V+33

v ~StubRoutines::call_stub

V [jvm.dll+0x86401]

V [jvm.dll+0xdb172]

V [jvm.dll+0x862d2]

V [jvm.dll+0x8602f]

V [jvm.dll+0xa0bcb]

V [jvm.dll+0x10bdad]

V [jvm.dll+0x10bd7b]

C [msvcrt.dll+0x2a3b0]

C [kernel32.dll+0xb683]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)

j gnu.io.RXTXVersion.nativeGetVersion()Ljava/lang/String;+0

j gnu.io.RXTXCommDriver.<clinit>()V+9

v ~StubRoutines::call_stub

j java.lang.Class.forName0(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;+0

j java.lang.Class.forName(Ljava/lang/String;)Ljava/lang/Class;+5

j gnu.io.CommPortIdentifier.<clinit>()V+12

v ~StubRoutines::call_stub

j com.foo.serial.SerialConnection.findTargetPort()Lgnu/io/CommPortIdentifier;+13

j com.foo.serial.SerialConnection.run()V+33

v ~StubRoutines::call_stub

P R O C E S S

Java Threads: ( => current thread )

0x0fd2e630 JavaThread "Thread-8" [_thread_blocked, id=3672]

0x0fd304e0 JavaThread "Thread-7" [_thread_blocked, id=4076]

=>0x0fd23458 JavaThread "Thread-5" [_thread_in_vm, id=3956]

0x0fd0b568 JavaThread "Image Fetcher 3" daemon [_thread_blocked, id=5632]

0x0fc498a8 JavaThread "Image Fetcher 2" daemon [_thread_blocked, id=5364]

0x0fc4fbc0 JavaThread "Image Fetcher 1" daemon [_thread_blocked, id=672]

0x0fc235a0 JavaThread "Image Fetcher 0" daemon [_thread_blocked, id=4204]

0x0fcead48 JavaThread "Thread-3" [_thread_in_native, id=5500]

0x0fc244c0 JavaThread "Thread-2" [_thread_blocked, id=5772]

0x0fc346f0 JavaThread "TimerQueue" daemon [_thread_blocked, id=676]

0x0fc07a60 JavaThread "AWT-EventQueue-0" [_thread_in_native, id=2268]

0x0fda0660 JavaThread "AWT-Shutdown" [_thread_blocked, id=3200]

0x0fd57ee8 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=184]

0x0fd77730 JavaThread "AWT-Windows" daemon [_thread_in_native, id=3204]

0x0f922780 JavaThread "Reader thread console tty" [_thread_in_native, id=5052]

0x0f91f220 JavaThread "console tty" [_thread_blocked, id=2676]

0x00326fe8 JavaThread "DestroyJavaVM" [_thread_blocked, id=3632]

0x0f91fbd8 JavaThread "startlevel job thread" [_thread_blocked, id=2192]

0x00f22e78 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=4580]

0x00f21ae8 JavaThread "CompilerThread0" daemon [_thread_blocked, id=1552]

0x00f20f28 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=4080]

0x00f17ce8 JavaThread "Finalizer" daemon [_thread_blocked, id=3124]

0x00f16850 JavaThread "Reference Handler" daemon [_thread_blocked, id=5552]

Other Threads:

0x00ed8a88 VMThread [id=1964]

0x00f20dd0 WatcherThread [id=3724]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap

def new generationtotal 9088K, used 5454K [0x02f60000, 0x03930000, 0x03960000)

eden space 8128K, 55% used [0x02f60000, 0x033c3960, 0x03750000)

from space 960K, 99% used [0x03840000, 0x0392fff8, 0x03930000)

tospace 960K,0% used [0x03750000, 0x03750000, 0x03840000)

tenured generationtotal 121024K, used 125K [0x03960000, 0x0af90000, 0x0b160000)

the space 121024K,0% used [0x03960000, 0x0397f718, 0x0397f800, 0x0af90000)

compacting perm gen total 9728K, used 9657K [0x0b160000, 0x0bae0000, 0x0f160000)

the space 9728K, 99% used [0x0b160000, 0x0bace720, 0x0bace800, 0x0bae0000)

No shared spaces configured.

Dynamic libraries:

0x00400000 - 0x0042f000 C:\dev\prgm_SerialTest\output\run.exe

0x7c900000 - 0x7c9b0000 C:\WINDOWS\system32\ntdll.dll

0x7c800000 - 0x7c8f4000 C:\WINDOWS\system32\kernel32.dll

0x77dd0000 - 0x77e6b000 C:\WINDOWS\system32\ADVAPI32.DLL

0x77e70000 - 0x77f01000 C:\WINDOWS\system32\RPCRT4.dll

0x71ad0000 - 0x71ad9000 C:\WINDOWS\system32\WSOCK32.DLL

0x71ab0000 - 0x71ac7000 C:\WINDOWS\system32\WS2_32.dll

0x77c10000 - 0x77c68000 C:\WINDOWS\system32\msvcrt.dll

0x71aa0000 - 0x71aa8000 C:\WINDOWS\system32\WS2HELP.dll

0x77d40000 - 0x77dd0000 C:\WINDOWS\system32\USER32.DLL

0x77f10000 - 0x77f57000 C:\WINDOWS\system32\GDI32.dll

0x6d6c0000 - 0x6d857000 C:\dev\prgm_SerialTest\output\jre\bin\client\jvm.dll

0x76b40000 - 0x76b6d000 C:\WINDOWS\system32\WINMM.dll

0x6d280000 - 0x6d288000 C:\dev\prgm_SerialTest\output\jre\bin\hpi.dll

0x76bf0000 - 0x76bfb000 C:\WINDOWS\system32\PSAPI.DLL

0x6d690000 - 0x6d69c000 C:\dev\prgm_SerialTest\output\jre\bin\verify.dll

0x6d300000 - 0x6d31d000 C:\dev\prgm_SerialTest\output\jre\bin\java.dll

0x6d6b0000 - 0x6d6bf000 C:\dev\prgm_SerialTest\output\jre\bin\zip.dll

0x6d4c0000 - 0x6d4d3000 C:\dev\prgm_SerialTest\output\jre\bin\net.dll

0x6d4e0000 - 0x6d4e9000 C:\dev\prgm_SerialTest\output\jre\bin\nio.dll

0x6d000000 - 0x6d167000 C:\dev\prgm_SerialTest\output\jre\bin\awt.dll

0x73000000 - 0x73026000 C:\WINDOWS\system32\WINSPOOL.DRV

0x76390000 - 0x763ad000 C:\WINDOWS\system32\IMM32.dll

0x774e0000 - 0x7761d000 C:\WINDOWS\system32\ole32.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

0x7c9c0000 - 0x7d1d5000 C:\WINDOWS\system32\shell32.dll

0x77f60000 - 0x77fd6000 C:\WINDOWS\system32\SHLWAPI.dll

0x773d0000 - 0x774d2000 C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll

0x5d090000 - 0x5d127000 C:\WINDOWS\system32\comctl32.dll

0x6d240000 - 0x6d27f000 C:\dev\prgm_SerialTest\output\jre\bin\fontmanager.dll

0x71a50000 - 0x71a8f000 C:\WINDOWS\System32\mswsock.dll

0x76f20000 - 0x76f47000 C:\WINDOWS\system32\DNSAPI.dll

0x76fb0000 - 0x76fb8000 C:\WINDOWS\System32\winrnr.dll

0x76f60000 - 0x76f8c000 C:\WINDOWS\system32\WLDAP32.dll

0x76fc0000 - 0x76fc6000 C:\WINDOWS\system32\rasadhlp.dll

0x662b0000 - 0x66308000 C:\WINDOWS\system32\hnetcfg.dll

0x71a90000 - 0x71a98000 C:\WINDOWS\System32\wshtcpip.dll

0x605d0000 - 0x605d9000 C:\WINDOWS\system32\mslbui.dll

0x77120000 - 0x771ac000 C:\WINDOWS\system32\OLEAUT32.DLL

0x101a0000 - 0x101b0000 C:\dev\prgm_SerialTest\output\jre\bin\rxtxSerial.dll

0x73d90000 - 0x73db7000 C:\WINDOWS\system32\crtdll.dll

VM Arguments:

jvm_args: -Djava.util.logging.config.file=config/logging.properties -Xms128m -Xmx129m -Dlauncher.config.params=-Djava.util.logging.config.file=config/logging.properties

-Xms128m

-Xmx129m -Dlauncher.config.classpath=C:\dev\prgm_SerialTest\output\run.exe;C:\dev\prgm_SerialTest\output\libraries\commons-net-1.4.1.jar;C:\dev\prgm_SerialTest\output\libraries\core_util.jar;C:\dev\prgm_SerialTest\output\libraries\kxml.jar;C:\dev\prgm_SerialTest\output\libraries\osgi.jar;C:\dev\prgm_SerialTest\output\libraries\substance-button-shaper-pack.jar;C:\dev\prgm_SerialTest\output\libraries\substance-watermark-pack.jar;C:\dev\prgm_SerialTest\output\libraries\substance.jar;C:\dev\prgm_SerialTest\output\framework\framework.jar -Dlauncher.program=C:\dev\prgm_SerialTest\output\run.exe -Dborland.executable.path=C:\dev\prgm_SerialTest\output\run.exe exit

java_command: <unknown>

Launcher Type: generic

Environment Variables:

JAVA_HOME=C:\Program Files\Java\jdk1.5.0_07

CLASSPATH=.;C:\Program Files\J-Integra\lib\jintegra.jar

PATH=C:\Python24;C:\Cygwin\usr\local\bin;C:\Cygwin\bin;C:\Cygwin\bin;C:\emacs-21.3\bin;C:\Cygwin\usr\X11R6\bin;C:\Program Files\Java\jdk1.5.0_07\bin;C:\WINDOWS\system32;.

USERNAME=pjflugst

DISPLAY=:0.0

OS=CYGWIN_NT-5.1

PROCESSOR_IDENTIFIER=x86 Family 15 Model 2 Stepping 9, GenuineIntel

S Y S T E M

OS: Windows XP Build 2600 Service Pack 2

CPU:total 1 family 15, cmov, cx8, fxsr, mmx, sse, sse2, ht

Memory: 4k page, physical 1570800k(795748k free), swap 2207104k(1492344k free)

vm_info: Java HotSpot(TM) Client VM (1.5.0_07-b03) for windows-x86, built on May 3 2006 01:04:38 by "java_re" with MS VC++ 6.0

pete.flugstada at 2007-7-14 20:40:10 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2

> I'm using the RXTX COMM jar/DLL for Windows XP

> (replacement for javax.comm API) from:

>

> http://www.rxtx.org/

>

> This uses JNI to talk to the Windows SerialPort/COM

> devices.

>

> When I use the stock binaries from the developer

> (built with GCC 2.95), they seem to work in all

> situations I test them.

>

> For a couple of reasons, I need to rebuild these

> libraries. I have a MinGW/MSYS environment with the

> current GCC release (gcc 3.4.2 (mingw-special)) and

> everything built fine with the provided makefiles.

>

> However, when I run some small tests with the

> resulting dll's, I seem some really weird behavior

> when i vary the Xms and Xmx value.I'm using Sun's

> JVM, 1.5.0_07.

That suggests that either you made an error in the way you built them or you are using a compiler option that is just incompatible with the VM.

jschella at 2007-7-14 20:40:10 > top of Java-index,Java HotSpot Virtual Machine,Specifications...