Hello,
I have a ROOT webapp running in "Tomcat 6.0.20 as a SERVICE" on
Windows 7 and it runs fine calling native code via JNI.
Now for debugging purposes :
I'm trying to run it with tomcat not running as a service (tomcat
started via startup.bat) and the load
of my bridge dll is ok, but as soon as I call the dll's init function
(CPPInit) it crashed the JVM.
If you look at the code you will see I try to create a file on the
root of the C drive (remotedebug.txt) and
this file never gets created but I don't think that is what is
causing the crash as CPPInit is called after
this file create and CPPInit seems to be what's failing.
See Code and JVM crash below.
Native Code Header:
/*
* Class: com_companyinc_direct_remote_bridge_RLBridge
* Method: cppInit
* Signature: (Ljava/lang/String;Ljava/lang/String;I[I)I
*/
JNIEXPORT jint JNICALL
Java_com_companyinc_direct_remote_bridge_RLBridge_cppInit
(JNIEnv *, jobject, jstring, jstring, jint, jintArray);
Native Code:
JNIEXPORT jint JNICALL
Java_com_companyinc_direct_remote_bridge_RLBridge_cppInit
(JNIEnv *env, jobject obj, jstring rdb, jstring jdb, jint dbl,
jintArray rtn)
{
int result;
int version;
jint *rtn_array;
wchar_t *rdb_str = (wchar_t *)env->GetStringChars(rdb, 0);
wchar_t *jdb_str = (wchar_t *)env->GetStringChars(jdb, 0);
rtn_array = env->GetIntArrayElements(rtn, FALSE);
const char *s1 = env->GetStringUTFChars(rdb, NULL);
const char *s2 = env->GetStringUTFChars(jdb, NULL);
//FILE *fp = fopen("C:\\remotedebug.txt", "at");
dbgout("CPP:Initializing bridge...");
dbgout(s1);
dbgout(s2);
//dbgout(rdb_str);
//dbgout(jdb_str);
// Turn on debugging stuff so we can see it...remember to turn this
off later!
RSWP_DBL(dbl);
dbgout("CPP:Debugging intialized.\n");
result = RSWP_Volumes(rdb_str, jdb_str, &version);
//result = rswpINVALID;
rtn_array[0] = version;
dbgout("CPP:Bridge Initialized.\n");
env->ReleaseStringChars(rdb, rdb_str);
env->ReleaseStringChars(jdb, jdb_str);
env->ReleaseIntArrayElements(rtn, rtn_array, 0);
// Ok, now, we have to dig deeper if there's an error
if (result == 2) // 2 means Dongle_INVALID, which is a catch-all for
Paul
{
// Is this ACTUALLY a dongle error?
if (RSWP_CheckHasp(TRUE) == 0)
{
// THis really isn't a HASP error, is it a DB error?
if (RSWP_SetDataBase(TRUE, NULL, 0) == 0)
{
// Not a DB error either, let's return the
WHO_KNOWS error (9)
result = 9;
}
else
{
// This is indeed a DB error, set the right
result
result = 4;
}
}
}
JVM CRASH:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x77c42272,
pid=2804, tid=3128
#
# JRE version: 6.0_18-b07
# Java VM: Java HotSpot(TM) Client VM (16.0-b13 mixed mode, sharing
windows-x86 )
# Problematic frame:
# C [ntdll.dll+0x22272]
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
--------------- T H R E A D ---------------
Current thread (0x050e5400): JavaThread "http-80-3" daemon
[_thread_in_native, id=3128, stack(0x05df0000,0x05e40000)]
siginfo: ExceptionCode=0xc0000005, writing address 0x00000024
Registers:
EAX=0x00000024, EBX=0x349ec398, ECX=0x05b5c5f8, EDX=0x00000005
ESP=0x05e3f578, EBP=0x05e3f58c, ESI=0x00000024, EDI=0x00000020
EIP=0x77c42272, EFLAGS=0x00010202
Top of Stack: (sp=0x05e3f578)
0x05e3f578: 050e5400 00000000 05b52eae 05b5c658
0x05e3f588: 05b5c034 05e3f5c0 05b52d56 00000020
0x05e3f598: 05b52e56 00000000 050e5400 349ec398
0x05e3f5a8: 349ec398 05b5104a 00000000 05b5c048
0x05e3f5b8: 05b5c04c 00000000 05e3f5e8 05b510c2
0x05e3f5c8: 05b5c04c 04c911a0 050eb120 349ec398
0x05e3f5d8: 04cfc008 04c90fc0 04cfc428 000e5400
0x05e3f5e8: 05e3f634 02569f47 050e5510 05e3f654
Instructions: (pc=0x77c42272)
0x77c42262: 55 8b ec 83 ec 0c 56 57 8b 7d 08 8d 77 04 8b c6
0x77c42272: f0 0f ba 30 00 0f 83 5e 01 01 00 64 a1 18 00 00
Stack: [0x05df0000,0x05e40000], sp=0x05e3f578, free space=13d05e3f05ck
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code,
C=native code)
C [ntdll.dll+0x22272]
C [RRBridge.dll+0x2d56]
C [RRBridge.dll+0x10c2]
j com.companyinc.direct.remote.bridge.RLBridge.cppInit(Ljava/lang/
String;Ljava/lang/String;I[I)I+0
j com.companyinc.direct.remote.bridge.RLBridge.init(Ljava/lang/
String;Ljava/lang/String;I)I+20
j com.companyinc.direct.RemoteServlet.init()V+563
j javax.servlet.GenericServlet.init(Ljavax/servlet/ServletConfig;)V+6
j org.apache.catalina.core.StandardWrapper.loadServlet()Ljavax/
servlet/Servlet;+774
j org.apache.catalina.core.StandardWrapper.allocate()Ljavax/servlet/
Servlet;+77
j org.apache.catalina.core.StandardWrapperValve.invoke(Lorg/apache/
catalina/connector/Request;Lorg/apache/catalina/connector/Response;)V
+199
j org.apache.catalina.core.StandardContextValve.invoke(Lorg/apache/
catalina/connector/Request;Lorg/apache/catalina/connector/Response;)V
+365
j org.apache.catalina.core.StandardHostValve.invoke(Lorg/apache/
catalina/connector/Request;Lorg/apache/catalina/connector/Response;)V+64
j org.apache.catalina.valves.ErrorReportValve.invoke(Lorg/apache/
catalina/connector/Request;Lorg/apache/catalina/connector/Response;)V+6
j org.apache.catalina.core.StandardEngineValve.invoke(Lorg/apache/
catalina/connector/Request;Lorg/apache/catalina/connector/Response;)V+42
j org.apache.catalina.connector.CoyoteAdapter.service(Lorg/apache/
coyote/Request;Lorg/apache/coyote/Response;)V+157
j org.apache.coyote.http11.Http11Processor.process(Ljava/net/Socket;)
V+432
j org.apache.coyote.http11.Http11Protocol
$Http11ConnectionHandler.process(Ljava/net/Socket;)Z+82
j org.apache.tomcat.util.net.JIoEndpoint$Worker.run()V+41
j java.lang.Thread.run()V+11
v ~StubRoutines::call_stub
V [jvm.dll+0xf072c]
V [jvm.dll+0x17fd51]
V [jvm.dll+0xf08f7]
V [jvm.dll+0xf096d]
V [jvm.dll+0x11a4c0]
V [jvm.dll+0x1dd924]
V [jvm.dll+0x17f9cc]
C [msvcr71.dll+0x9565]
C [kernel32.dll+0x13677]
C [ntdll.dll+0x39d72]
C [ntdll.dll+0x39d45]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j com.companyinc.direct.remote.bridge.RLBridge.cppInit(Ljava/lang/
String;Ljava/lang/String;I[I)I+0
j com.companyinc.direct.remote.bridge.RLBridge.init(Ljava/lang/
String;Ljava/lang/String;I)I+20
j com.companyinc.direct.RemoteServlet.init()V+563
j javax.servlet.GenericServlet.init(Ljavax/servlet/ServletConfig;)V+6
j org.apache.catalina.core.StandardWrapper.loadServlet()Ljavax/
servlet/Servlet;+774
j org.apache.catalina.core.StandardWrapper.allocate()Ljavax/servlet/
Servlet;+77
j org.apache.catalina.core.StandardWrapperValve.invoke(Lorg/apache/
catalina/connector/Request;Lorg/apache/catalina/connector/Response;)V
+199
j org.apache.catalina.core.StandardContextValve.invoke(Lorg/apache/
catalina/connector/Request;Lorg/apache/catalina/connector/Response;)V
+365
j org.apache.catalina.core.StandardHostValve.invoke(Lorg/apache/
catalina/connector/Request;Lorg/apache/catalina/connector/Response;)V+64
j org.apache.catalina.valves.ErrorReportValve.invoke(Lorg/apache/
catalina/connector/Request;Lorg/apache/catalina/connector/Response;)V+6
j org.apache.catalina.core.StandardEngineValve.invoke(Lorg/apache/
catalina/connector/Request;Lorg/apache/catalina/connector/Response;)V+42
j org.apache.catalina.connector.CoyoteAdapter.service(Lorg/apache/
coyote/Request;Lorg/apache/coyote/Response;)V+157
j org.apache.coyote.http11.Http11Processor.process(Ljava/net/Socket;)
V+432
j org.apache.coyote.http11.Http11Protocol
$Http11ConnectionHandler.process(Ljava/net/Socket;)Z+82
j org.apache.tomcat.util.net.JIoEndpoint$Worker.run()V+41
j java.lang.Thread.run()V+11
v ~StubRoutines::call_stub
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
=>0x050e5400 JavaThread "http-80-3" daemon [_thread_in_native,
id=3128, stack(0x05df0000,0x05e40000)]
0x050e5000 JavaThread "http-80-2" daemon [_thread_in_native,
id=3600, stack(0x05d60000,0x05db0000)]
0x04f74000 JavaThread "http-80-1" daemon [_thread_in_native,
id=4756, stack(0x05850000,0x058a0000)]
0x04fdbc00 JavaThread "TP-Monitor" daemon [_thread_blocked,
id=4420, stack(0x055f0000,0x05640000)]
0x04fdb800 JavaThread "TP-Processor4" daemon [_thread_in_native,
id=4056, stack(0x05560000,0x055b0000)]
0x04fdb000 JavaThread "TP-Processor3" daemon [_thread_blocked,
id=4356, stack(0x054d0000,0x05520000)]
0x04f56000 JavaThread "TP-Processor2" daemon [_thread_blocked,
id=4208, stack(0x05440000,0x05490000)]
0x04f55c00 JavaThread "TP-Processor1" daemon [_thread_blocked,
id=1796, stack(0x053b0000,0x05400000)]
0x04fd8c00 JavaThread "http-80-Acceptor-0" daemon
[_thread_in_native, id=4628, stack(0x052d0000,0x05320000)]
0x04fd8400 JavaThread "ContainerBackgroundProcessor[StandardEngine
[Catalina]]" daemon [_thread_blocked, id=3624, stack
(0x05280000,0x052d0000)]
0x024d6c00 JavaThread "Low Memory Detector" daemon
[_thread_blocked, id=3520, stack(0x04a10000,0x04a60000)]
0x024c7c00 JavaThread "CompilerThread0" daemon [_thread_blocked,
id=1200, stack(0x04980000,0x049d0000)]
0x024c6800 JavaThread "Attach Listener" daemon [_thread_blocked,
id=2452, stack(0x048f0000,0x04940000)]
0x024c3c00 JavaThread "Signal Dispatcher" daemon [_thread_blocked,
id=3112, stack(0x04860000,0x048b0000)]
0x024bac00 JavaThread "Finalizer" daemon [_thread_blocked,
id=4196, stack(0x047d0000,0x04820000)]
0x024b9400 JavaThread "Reference Handler" daemon [_thread_blocked,
id=3864, stack(0x04740000,0x04790000)]
0x0027b000 JavaThread "main" [_thread_in_native, id=1204, stack
(0x00430000,0x00480000)]
Other Threads:
0x024b7c00 VMThread [stack: 0x046b0000,0x04700000] [id=284]
0x024df800 WatcherThread [stack: 0x04aa0000,0x04af0000] [id=4480]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
Heap
def new generation total 4928K, used 4268K [0x24250000,
0x247a0000, 0x297a0000)
eden space 4416K, 85% used [0x24250000, 0x245fb3a0, 0x246a0000)
from space 512K, 100% used [0x246a0000, 0x24720000, 0x24720000)
to space 512K, 0% used [0x24720000, 0x24720000, 0x247a0000)
tenured generation total 10944K, used 3209K [0x297a0000,
0x2a250000, 0x34250000)
the space 10944K, 29% used [0x297a0000, 0x29ac2438, 0x29ac2600,
0x2a250000)
compacting perm gen total 12288K, used 7880K [0x34250000,
0x34e50000, 0x38250000)
the space 12288K, 64% used [0x34250000, 0x34a023d0, 0x34a02400,
0x34e50000)
ro space 10240K, 51% used [0x38250000, 0x38777b58, 0x38777c00,
0x38c50000)
rw space 12288K, 54% used [0x38c50000, 0x392e4ce0, 0x392e4e00,
0x39850000)
Dynamic libraries:
0x00400000 - 0x00424000 C:\Program Files (x86)\Java\jre6\bin\java.exe
0x77c20000 - 0x77da0000 C:\Windows\SysWOW64\ntdll.dll
0x75de0000 - 0x75ee0000 C:\Windows\syswow64\kernel32.dll
0x76630000 - 0x76676000 C:\Windows\syswow64\KERNELBASE.dll
0x75930000 - 0x759d0000 C:\Windows\syswow64\ADVAPI32.dll
0x75bf0000 - 0x75c9c000 C:\Windows\syswow64\msvcrt.dll
0x75910000 - 0x75929000 C:\Windows\SysWOW64\sechost.dll
0x76450000 - 0x76540000 C:\Windows\syswow64\RPCRT4.dll
0x75790000 - 0x757f0000 C:\Windows\syswow64\SspiCli.dll
0x75780000 - 0x7578c000 C:\Windows\syswow64\CRYPTBASE.dll
0x7c340000 - 0x7c396000 C:\Program Files (x86)\Java\jre6\bin
\msvcr71.dll
0x6d800000 - 0x6da97000 C:\Program Files (x86)\Java\jre6\bin\client
\jvm.dll
0x76680000 - 0x76780000 C:\Windows\syswow64\USER32.dll
0x75ac0000 - 0x75b50000 C:\Windows\syswow64\GDI32.dll
0x760a0000 - 0x760aa000 C:\Windows\syswow64\LPK.dll
0x75b50000 - 0x75bed000 C:\Windows\syswow64\USP10.dll
0x75300000 - 0x75332000 C:\Windows\system32\WINMM.dll
0x777c0000 - 0x77820000 C:\Windows\system32\IMM32.DLL
0x77530000 - 0x775fc000 C:\Windows\syswow64\MSCTF.dll
0x734e0000 - 0x7352b000 C:\Windows\system32\apphelp.dll
0x6d7b0000 - 0x6d7bc000 C:\Program Files (x86)\Java\jre6\bin\verify.dll
0x6d330000 - 0x6d34f000 C:\Program Files (x86)\Java\jre6\bin\java.dll
0x6d290000 - 0x6d298000 C:\Program Files (x86)\Java\jre6\bin\hpi.dll
0x77520000 - 0x77525000 C:\Windows\syswow64\PSAPI.DLL
0x6d7f0000 - 0x6d7ff000 C:\Program Files (x86)\Java\jre6\bin\zip.dll
0x6d610000 - 0x6d623000 C:\Program Files (x86)\Java\jre6\bin\net.dll
0x76410000 - 0x76445000 C:\Windows\syswow64\WS2_32.dll
0x77bf0000 - 0x77bf6000 C:\Windows\syswow64\NSI.dll
0x737c0000 - 0x737fc000 C:\Windows\system32\mswsock.dll
0x737b0000 - 0x737b6000 C:\Windows\System32\wship6.dll
0x73c30000 - 0x73c35000 C:\Windows\System32\wshtcpip.dll
0x73760000 - 0x737a4000 C:\Windows\system32\DNSAPI.dll
0x736e0000 - 0x736fc000 C:\Windows\system32\IPHLPAPI.DLL
0x736d0000 - 0x736d7000 C:\Windows\system32\WINNSI.DLL
0x73730000 - 0x73736000 C:\Windows\system32\rasadhlp.dll
0x73250000 - 0x73288000 C:\Windows\System32\fwpuclnt.dll
0x73e70000 - 0x73e86000 C:\Windows\system32\CRYPTSP.dll
0x73e30000 - 0x73e6b000 C:\Windows\system32\rsaenh.dll
0x73c00000 - 0x73c17000 C:\Windows\system32\USERENV.dll
0x73bf0000 - 0x73bfb000 C:\Windows\system32\profapi.dll
0x73740000 - 0x73750000 C:\Windows\system32\NLAapi.dll
0x73750000 - 0x73758000 C:\Windows\System32\winrnr.dll
0x73720000 - 0x73730000 C:\Windows\system32\napinsp.dll
0x73700000 - 0x73712000 C:\Windows\system32\pnrpnsp.dll
0x10000000 - 0x10019000 C:\Tomcat6\apache-tomcat-6.0.20\temp
\jna5344501454009210051.tmp
0x004b0000 - 0x004b6000 c:\rsi_rr\ramout\HaspBridge.dll
0x058a0000 - 0x05952000 C:\rsi_rr\ramout\RSI_haspN.dll
0x73b30000 - 0x73bcb000 C:\Windows\WinSxS
\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4927_none_d08a205e442
db5b5\MSVCR80.dll
0x746e0000 - 0x747f0000 C:\Windows\WinSxS
\x86_microsoft.vc80.mfc_1fc8b3b9a1e18e3b_8.0.50727.4053_none_cbf21254470
d8752\MFC80.DLL
0x75a60000 - 0x75ab7000 C:\Windows\syswow64\SHLWAPI.dll
0x73350000 - 0x7335e000 C:\Windows\WinSxS
\x86_microsoft.vc80.mfcloc_1fc8b3b9a1e18e3b_8.0.50727.4053_none_03ca5532
205cb096\MFC80ENU.DLL
0x73d80000 - 0x73d8d000 C:\Windows\system32\wtsapi32.dll
0x717b0000 - 0x71830000 C:\Windows\system32\uxtheme.dll
0x05b50000 - 0x05b60000 C:\rsi_rr\ramout\RRBridge.dll
0x05e40000 - 0x05ebe000 C:\rsi_rr\ramout\WebProductU.dll
0x05ec0000 - 0x05eff000 C:\rsi_rr\ramout\LIBMYSQL.dll
0x73e90000 - 0x73e97000 C:\Windows\system32\WSOCK32.dll
0x05f40000 - 0x05fec000 C:\rsi_rr\ramout\snbd12cm.dll
0x05d30000 - 0x05d41000 C:\rsi_rr\ramout\zlib.dll
0x6c240000 - 0x6c267000 C:\Windows\system32\CRTDLL.dll
0x05ff0000 - 0x0603f000 C:\rsi_rr\ramout\LogoSync.dll
0x55300000 - 0x554ca000 C:\rsi_rr\ramout\pdflib.dll
0x680b0000 - 0x681cf000 C:\Windows\system32\MFC42u.DLL
0x760b0000 - 0x7620c000 C:\Windows\syswow64\ole32.dll
0x76540000 - 0x765cf000 C:\Windows\syswow64\OLEAUT32.dll
0x6cf60000 - 0x6cfea000 C:\Windows\system32\ODBC32.dll
0x06040000 - 0x0609b000 C:\rsi_rr\ramout\filenamesU.dll
0x73640000 - 0x73652000 C:\Windows\system32\MPR.dll
0x6b050000 - 0x6b0b6000 C:\Windows\system32\MSVCP60.dll
0x74bc0000 - 0x74bf8000 C:\Windows\system32\odbcint.dll
0x060a0000 - 0x060c4000 C:\rsi_rr\ramout\CALWIN32.DLL
0x060d0000 - 0x060e3000 C:\rsi_rr\ramout\CLNWIN32.DLL
0x06110000 - 0x0612c000 C:\rsi_rr\ramout\LOCWIN32.DLL
0x06460000 - 0x06487000 C:\rsi_rr\ramout\NCPWIN32.dll
0x06b20000 - 0x06ccc000 C:\rsi_rr\ramout\RampageResourcesENUU.dll
0x069a0000 - 0x06aaf000 C:\Windows\WinSxS
\x86_microsoft.vc80.mfc_1fc8b3b9a1e18e3b_8.0.50727.4053_none_cbf21254470
d8752\MFC80U.DLL
VM Arguments:
jvm_args: -Djava.util.logging.config.file=C:\Tomcat6\apache-
tomcat-6.0.20\conf\logging.properties -
Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -
Djava.endorsed.dirs=C:\Tomcat6\apache-tomcat-6.0.20\endorsed -
Dcatalina.base=C:\Tomcat6\apache-tomcat-6.0.20 -Dcatalina.home=C:
\Tomcat6\apache-tomcat-6.0.20 -Djava.io.tmpdir=C:\Tomcat6\apache-
tomcat-6.0.20\temp
java_command: org.apache.catalina.startup.Bootstrap start
Launcher Type: SUN_STANDARD
Environment Variables:
JRE_HOME=C:\Program Files (x86)\Java\jre6
CLASSPATH=;C:\Tomcat6\apache-tomcat-6.0.20\bin\bootstrap.jar
PATH=C:\Program Files (x86)\Intel\Compiler\11.1\054\tbb\intel64\vc8
\bin;C:\Program Files (x86)\Intel\Compiler\11.1\054\lib\ia32;C:
\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows
\System32\WindowsPowerShell\v1.0\;C:\rsi_rr\ramout;C:\rsi;C:\rsi
\ramout;C:\rsi\HQN;C:\Program Files (x86)\Common Files\Acronis\SnapAPI
\;C:\Program Files\Intel\DMIX
USERNAME=rip
OS=Windows_NT
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 26 Stepping 5, GenuineIntel
--------------- S Y S T E M ---------------
OS: Windows 7 Build 7600
CPU:total 8 (8 cores per cpu, 2 threads per core) family 6 model 26
stepping 5, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1,
sse4.2, popcnt, ht
Memory: 4k page, physical 8327308k(6152880k free), swap 16652720k
(14290640k free)
vm_info: Java HotSpot(TM) Client VM (16.0-b13) for windows-x86 JRE
(1.6.0_18-b07), built on Dec 17 2009 13:35:55 by "java_re" with MS VC+
+ 7.1 (VS2003)
time: Sat Mar 27 17:17:32 2010
elapsed time: 33 seconds