Skip to content

Commit

Permalink
Sourceforge 2011706 windows memory error when exiting program with ca…
Browse files Browse the repository at this point in the history
…ll back proxies still hooked up.
  • Loading branch information
clay_shooter committed Jul 6, 2008
1 parent d024675 commit 2406511
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 93 deletions.
41 changes: 41 additions & 0 deletions jacob/docs/ReleaseNotes.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
<HTML>
<BODY>
<!-- --------- -->
<h2>JACOB 1.14.2</h2>
<h3>Tracked Changes</h3>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" >
<tr>
<td width="100%" colspan="2"><b>Bugs</b></td>
</tr>
<tr>
<td width="13%" valign="top">2011706</td>
<td width="87%" valign="top">Fixed windows memory corruption unhooking
call back proxies</td>
</tr>
<tr>
<td width="13%" valign="top">&nbsp;</td>
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Patches</b></td>
</tr>
<tr>
<td width="13%" valign="top">&nbsp;</td>
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Feature Requests</b></td>
</tr>
<tr>
<td width="13%" valign="top">&nbsp;</td>
<td width="87%" valign="top">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2"><b>Known Issues</b></td>
</tr>
<tr>
<td width="13%" valign="top"></td>
<td width="87%" valign="top"></td>
</tr>

</table>


<!-- --------- -->
<h2>JACOB 1.14.1</h2>
<h3>Tracked Changes</h3>
Expand Down
4 changes: 2 additions & 2 deletions jacob/docs/UsingJacob.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ <h3>Classloader issues</h3>
<h2>Microsoft Visual C++ library dependencies.</h2>
Jacob 1.13 is built with VC++ 2005 that creates a dependency on msvcr80.dll.
Windows XP and later seem to already include the necessary components.
NT/2000 and Server/2003 require that you download the Visual C redistributable package,
vcredist_x86.exe from the microsoft web site.
NT/2000 and Server/2003 require that you download the Visual C 2005 redistributable
package, vcredist_x86.exe from the microsoft web site.
Microsoft has a download available that supplies the necessary components.
It is distributed as a redistributable package.
<p>
Expand Down
25 changes: 14 additions & 11 deletions jacob/jni/EventProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,33 +60,36 @@ EventProxy::~EventProxy()
JNIEnv *env;
Disconnect();
jint vmConnectionStatus = JNI_EVERSION ;

jint attachReturnStatus = -1; // AttachCurrentThread return status.. negative numbers are failure return codes.

// attach to the current running thread -- JDK 1.4 jni.h has two param cover for 3 param call
vmConnectionStatus = jvm->GetEnv((void **)&env, JNI_VERSION_1_2);
if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();}
if ((env != NULL)&& env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();}
if (vmConnectionStatus == JNI_EDETACHED){
//printf("Unhook: Attaching to current thread using JNI Version 1.2 (%d)\n",vmConnectionStatus);
JavaVMAttachArgs attachmentArgs;
attachmentArgs.version = JNI_VERSION_1_2;
attachmentArgs.name = NULL;
attachmentArgs.group = NULL;
jvm->AttachCurrentThread((void **)&env, &attachmentArgs);
if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();}
attachReturnStatus = jvm->AttachCurrentThread((void **)&env, &attachmentArgs);
if ((env != NULL) && env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();}
} else {
// should really look for JNI_OK versus an error
// started method hooked so no need to attach again
// should really look for JNI_OK versus an error because it could have been JNI_EVERSION
// started method with thread hooked to VM so no need to attach again
//printf("Unhook: No need to attach because already attached %d\n",vmConnectionStatus);
}


env->DeleteGlobalRef(javaSinkObj);
if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();}
// we should always have an env by this point but lets be paranoid and check
if (env != NULL){
env->DeleteGlobalRef(javaSinkObj);
if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();}
}
if (MethNum) {
delete [] MethName;
delete [] MethID;
}
// detach from thread
if (vmConnectionStatus == JNI_EDETACHED){
// detach from thread only if we attached to it in this function
if (attachReturnStatus == 0){
jvm->DetachCurrentThread();
//printf("Unhook: Detached\n");
} else {
Expand Down
Loading

0 comments on commit 2406511

Please sign in to comment.