JNI with 1 byte alignment crashes JVM

D

Dave Rathnow

I've been trying to write some JNI code to allow a my Java code to interact
with some C/C++ libraries (Win2K, with MSVC 7.) My code passes arrays
of bytes back and forth between Java and the native code. I was able to
get things to the point where the code would run but the final byte array
that
was suppose to come back from my native code was empty. I finally wrote
test C program and I found it had the same problems. I change the
structure alignment to 1 byte alignment and the C program started doing the
right thing. Unfortunately, I didn't have the same luck with my Java
program.
Now, instead of not working, it crashes the JVM. The dump is at the bottom,
but I was wondering if anyone else has had a similar experience?

Thanks
Dave.

Unexpected Signal : EXCEPTION_PRIV_INSTRUCTION occurred at PC=0x9923F1
Function=[Unknown.]
Library=(N/A)

NOTE: We are unable to locate the function name symbol for the error
just occurred. Please refer to release documentation for possible
reason and solutions.


Current Java thread:

Dynamic libraries:
0x00400000 - 0x00407000 C:\JBuilder9\jdk1.4\bin\javaw.exe
0x77F80000 - 0x77FFB000 C:\WINNT\system32\ntdll.dll
0x7C2D0000 - 0x7C332000 C:\WINNT\system32\ADVAPI32.dll
0x7C570000 - 0x7C623000 C:\WINNT\system32\KERNEL32.DLL
0x77D30000 - 0x77D9E000 C:\WINNT\system32\RPCRT4.DLL
0x77E10000 - 0x77E6F000 C:\WINNT\system32\USER32.dll
0x77F40000 - 0x77F79000 C:\WINNT\system32\GDI32.dll
0x78000000 - 0x78045000 C:\WINNT\system32\MSVCRT.dll
0x75E60000 - 0x75E7A000 C:\WINNT\system32\IMM32.DLL
0x6D340000 - 0x6D46A000 C:\JBuilder9\jdk1.4\jre\bin\client\jvm.dll
0x77570000 - 0x775A0000 C:\WINNT\system32\WINMM.dll
0x6D1E0000 - 0x6D1E7000 C:\JBuilder9\jdk1.4\jre\bin\hpi.dll
0x6D310000 - 0x6D31E000 C:\JBuilder9\jdk1.4\jre\bin\verify.dll
0x6D220000 - 0x6D239000 C:\JBuilder9\jdk1.4\jre\bin\java.dll
0x6D330000 - 0x6D33D000 C:\JBuilder9\jdk1.4\jre\bin\zip.dll
0x6D2E0000 - 0x6D2EE000 C:\JBuilder9\jdk1.4\jre\bin\net.dll
0x75050000 - 0x75058000 C:\WINNT\system32\WSOCK32.dll
0x75030000 - 0x75044000 C:\WINNT\system32\WS2_32.DLL
0x75020000 - 0x75028000 C:\WINNT\system32\WS2HELP.DLL
0x782C0000 - 0x782CC000 C:\WINNT\System32\rnr20.dll
0x77980000 - 0x779A4000 C:\WINNT\system32\DNSAPI.DLL
0x77340000 - 0x77353000 C:\WINNT\system32\iphlpapi.dll
0x77520000 - 0x77525000 C:\WINNT\system32\ICMP.DLL
0x77320000 - 0x77337000 C:\WINNT\system32\MPRAPI.DLL
0x75150000 - 0x7515F000 C:\WINNT\system32\SAMLIB.DLL
0x75170000 - 0x751BF000 C:\WINNT\system32\NETAPI32.DLL
0x7C340000 - 0x7C34F000 C:\WINNT\system32\SECUR32.DLL
0x751C0000 - 0x751C6000 C:\WINNT\system32\NETRAP.DLL
0x77950000 - 0x7797A000 C:\WINNT\system32\WLDAP32.DLL
0x77A50000 - 0x77B3C000 C:\WINNT\system32\OLE32.DLL
0x779B0000 - 0x77A4B000 C:\WINNT\system32\OLEAUT32.DLL
0x773B0000 - 0x773DF000 C:\WINNT\system32\ACTIVEDS.DLL
0x77380000 - 0x773A3000 C:\WINNT\system32\ADSLDPC.DLL
0x77830000 - 0x7783E000 C:\WINNT\system32\RTUTILS.DLL
0x77880000 - 0x7790E000 C:\WINNT\system32\SETUPAPI.DLL
0x7C0F0000 - 0x7C151000 C:\WINNT\system32\USERENV.DLL
0x774E0000 - 0x77513000 C:\WINNT\system32\RASAPI32.DLL
0x774C0000 - 0x774D1000 C:\WINNT\system32\RASMAN.DLL
0x77530000 - 0x77552000 C:\WINNT\system32\TAPI32.DLL
0x71710000 - 0x71794000 C:\WINNT\system32\COMCTL32.DLL
0x63180000 - 0x631E5000 C:\WINNT\system32\SHLWAPI.DLL
0x77360000 - 0x77379000 C:\WINNT\system32\DHCPCSVC.DLL
0x777E0000 - 0x777E8000 C:\WINNT\System32\winrnr.dll
0x0B2E0000 - 0x0B31A000 C:\Program Files\NewDotNet\newdotnet5_48.dll
0x70200000 - 0x70295000 C:\WINNT\system32\WININET.dll
0x77440000 - 0x774B8000 C:\WINNT\system32\CRYPT32.dll
0x77430000 - 0x77440000 C:\WINNT\system32\MSASN1.DLL
0x76620000 - 0x76631000 C:\WINNT\system32\MPR.dll
0x76930000 - 0x7695B000 C:\WINNT\system32\WINTRUST.dll
0x77920000 - 0x77943000 C:\WINNT\system32\IMAGEHLP.dll
0x77820000 - 0x77827000 C:\WINNT\system32\VERSION.dll
0x759B0000 - 0x759B6000 C:\WINNT\system32\LZ32.DLL
0x782F0000 - 0x78538000 C:\WINNT\system32\SHELL32.dll
0x777F0000 - 0x777F5000 C:\WINNT\system32\rasadhlp.dll
0x74FD0000 - 0x74FEE000 C:\WINNT\system32\msafd.dll
0x75010000 - 0x75017000 C:\WINNT\System32\wshtcpip.dll
0x10000000 - 0x10045000 C:\WINNT\system32\jstp.dll
0x72A00000 - 0x72A2D000 C:\WINNT\system32\DBGHELP.dll
0x690A0000 - 0x690AB000 C:\WINNT\system32\PSAPI.DLL

Local Time = Thu Nov 06 20:07:17 2003
Elapsed Time = 7
#
# HotSpot Virtual Machine Error : EXCEPTION_PRIV_INSTRUCTION
# Error ID : 4F530E43505002E6
# Please report this error at
# http://java.sun.com/cgi-bin/bugreport.cgi
#
# Java VM: Java HotSpot(TM) Client VM (1.4.1_02-b06 mixed mode)
#
 
N

nos

compile with -g

Dave Rathnow said:
I've been trying to write some JNI code to allow a my Java code to interact
with some C/C++ libraries (Win2K, with MSVC 7.) My code passes arrays
of bytes back and forth between Java and the native code. I was able to
get things to the point where the code would run but the final byte array
that
was suppose to come back from my native code was empty. I finally wrote
test C program and I found it had the same problems. I change the
structure alignment to 1 byte alignment and the C program started doing the
right thing. Unfortunately, I didn't have the same luck with my Java
program.
Now, instead of not working, it crashes the JVM. The dump is at the bottom,
but I was wondering if anyone else has had a similar experience?

Thanks
Dave.

Unexpected Signal : EXCEPTION_PRIV_INSTRUCTION occurred at PC=0x9923F1
Function=[Unknown.]
Library=(N/A)

NOTE: We are unable to locate the function name symbol for the error
just occurred. Please refer to release documentation for possible
reason and solutions.


Current Java thread:

Dynamic libraries:
0x00400000 - 0x00407000 C:\JBuilder9\jdk1.4\bin\javaw.exe
0x77F80000 - 0x77FFB000 C:\WINNT\system32\ntdll.dll
0x7C2D0000 - 0x7C332000 C:\WINNT\system32\ADVAPI32.dll
0x7C570000 - 0x7C623000 C:\WINNT\system32\KERNEL32.DLL
0x77D30000 - 0x77D9E000 C:\WINNT\system32\RPCRT4.DLL
0x77E10000 - 0x77E6F000 C:\WINNT\system32\USER32.dll
0x77F40000 - 0x77F79000 C:\WINNT\system32\GDI32.dll
0x78000000 - 0x78045000 C:\WINNT\system32\MSVCRT.dll
0x75E60000 - 0x75E7A000 C:\WINNT\system32\IMM32.DLL
0x6D340000 - 0x6D46A000 C:\JBuilder9\jdk1.4\jre\bin\client\jvm.dll
0x77570000 - 0x775A0000 C:\WINNT\system32\WINMM.dll
0x6D1E0000 - 0x6D1E7000 C:\JBuilder9\jdk1.4\jre\bin\hpi.dll
0x6D310000 - 0x6D31E000 C:\JBuilder9\jdk1.4\jre\bin\verify.dll
0x6D220000 - 0x6D239000 C:\JBuilder9\jdk1.4\jre\bin\java.dll
0x6D330000 - 0x6D33D000 C:\JBuilder9\jdk1.4\jre\bin\zip.dll
0x6D2E0000 - 0x6D2EE000 C:\JBuilder9\jdk1.4\jre\bin\net.dll
0x75050000 - 0x75058000 C:\WINNT\system32\WSOCK32.dll
0x75030000 - 0x75044000 C:\WINNT\system32\WS2_32.DLL
0x75020000 - 0x75028000 C:\WINNT\system32\WS2HELP.DLL
0x782C0000 - 0x782CC000 C:\WINNT\System32\rnr20.dll
0x77980000 - 0x779A4000 C:\WINNT\system32\DNSAPI.DLL
0x77340000 - 0x77353000 C:\WINNT\system32\iphlpapi.dll
0x77520000 - 0x77525000 C:\WINNT\system32\ICMP.DLL
0x77320000 - 0x77337000 C:\WINNT\system32\MPRAPI.DLL
0x75150000 - 0x7515F000 C:\WINNT\system32\SAMLIB.DLL
0x75170000 - 0x751BF000 C:\WINNT\system32\NETAPI32.DLL
0x7C340000 - 0x7C34F000 C:\WINNT\system32\SECUR32.DLL
0x751C0000 - 0x751C6000 C:\WINNT\system32\NETRAP.DLL
0x77950000 - 0x7797A000 C:\WINNT\system32\WLDAP32.DLL
0x77A50000 - 0x77B3C000 C:\WINNT\system32\OLE32.DLL
0x779B0000 - 0x77A4B000 C:\WINNT\system32\OLEAUT32.DLL
0x773B0000 - 0x773DF000 C:\WINNT\system32\ACTIVEDS.DLL
0x77380000 - 0x773A3000 C:\WINNT\system32\ADSLDPC.DLL
0x77830000 - 0x7783E000 C:\WINNT\system32\RTUTILS.DLL
0x77880000 - 0x7790E000 C:\WINNT\system32\SETUPAPI.DLL
0x7C0F0000 - 0x7C151000 C:\WINNT\system32\USERENV.DLL
0x774E0000 - 0x77513000 C:\WINNT\system32\RASAPI32.DLL
0x774C0000 - 0x774D1000 C:\WINNT\system32\RASMAN.DLL
0x77530000 - 0x77552000 C:\WINNT\system32\TAPI32.DLL
0x71710000 - 0x71794000 C:\WINNT\system32\COMCTL32.DLL
0x63180000 - 0x631E5000 C:\WINNT\system32\SHLWAPI.DLL
0x77360000 - 0x77379000 C:\WINNT\system32\DHCPCSVC.DLL
0x777E0000 - 0x777E8000 C:\WINNT\System32\winrnr.dll
0x0B2E0000 - 0x0B31A000 C:\Program Files\NewDotNet\newdotnet5_48.dll
0x70200000 - 0x70295000 C:\WINNT\system32\WININET.dll
0x77440000 - 0x774B8000 C:\WINNT\system32\CRYPT32.dll
0x77430000 - 0x77440000 C:\WINNT\system32\MSASN1.DLL
0x76620000 - 0x76631000 C:\WINNT\system32\MPR.dll
0x76930000 - 0x7695B000 C:\WINNT\system32\WINTRUST.dll
0x77920000 - 0x77943000 C:\WINNT\system32\IMAGEHLP.dll
0x77820000 - 0x77827000 C:\WINNT\system32\VERSION.dll
0x759B0000 - 0x759B6000 C:\WINNT\system32\LZ32.DLL
0x782F0000 - 0x78538000 C:\WINNT\system32\SHELL32.dll
0x777F0000 - 0x777F5000 C:\WINNT\system32\rasadhlp.dll
0x74FD0000 - 0x74FEE000 C:\WINNT\system32\msafd.dll
0x75010000 - 0x75017000 C:\WINNT\System32\wshtcpip.dll
0x10000000 - 0x10045000 C:\WINNT\system32\jstp.dll
0x72A00000 - 0x72A2D000 C:\WINNT\system32\DBGHELP.dll
0x690A0000 - 0x690AB000 C:\WINNT\system32\PSAPI.DLL

Local Time = Thu Nov 06 20:07:17 2003
Elapsed Time = 7
#
# HotSpot Virtual Machine Error : EXCEPTION_PRIV_INSTRUCTION
# Error ID : 4F530E43505002E6
# Please report this error at
# http://java.sun.com/cgi-bin/bugreport.cgi
#
# Java VM: Java HotSpot(TM) Client VM (1.4.1_02-b06 mixed mode)
#
 
G

Gordon Beaton

I've been trying to write some JNI code to allow a my Java code to
interact with some C/C++ libraries (Win2K, with MSVC 7.) My code
passes arrays of bytes back and forth between Java and the native
code. I was able to get things to the point where the code would run
but the final byte array that was suppose to come back from my
native code was empty. I finally wrote test C program and I found it
had the same problems. I change the structure alignment to 1 byte
alignment and the C program started doing the right thing.
Unfortunately, I didn't have the same luck with my Java program.

Now, instead of not working, it crashes the JVM. The dump is at the
bottom, but I was wondering if anyone else has had a similar
experience?

I'll go out on a limb here and suggest that you didn't solve the
original problem correctly when you changed the structure alignment.

The JVM was not compiled that way, so it and your native methods
disagree on the representation of the structures defined in the jni
header files. I'm not surprised that it crashes as a result.

/gordon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top