This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libgcj/13212] JNI/CNI AttachCurrentThread does not register thread with garbage collector
- From: "stewart at neuron dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Oct 2005 20:29:38 -0000
- Subject: [Bug libgcj/13212] JNI/CNI AttachCurrentThread does not register thread with garbage collector
- References: <bug-13212-7355@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #12 from stewart at neuron dot com 2005-10-12 20:29 -------
Tom,
This patch from you against gcc-4.0.2 cured the segfault.
Thanks,
Stewart
Index: jni.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni.cc,v
retrieving revision 1.95.2.2
diff -u -r1.95.2.2 jni.cc
--- jni.cc 6 Sep 2005 16:03:11 -0000 1.95.2.2
+++ jni.cc 12 Oct 2005 18:50:20 -0000
@@ -2341,10 +2341,14 @@
}
// Attaching an already-attached thread is a no-op.
- if (_Jv_GetCurrentJNIEnv () != NULL)
- return 0;
+ JNIEnv *env = _Jv_GetCurrentJNIEnv ();
+ if (env != NULL)
+ {
+ *penv = reinterpret_cast<void *> (env);
+ return 0;
+ }
- JNIEnv *env = (JNIEnv *) _Jv_MallocUnchecked (sizeof (JNIEnv));
+ env = (JNIEnv *) _Jv_MallocUnchecked (sizeof (JNIEnv));
if (env == NULL)
return JNI_ERR;
env->p = &_Jv_JNIFunctions;
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13212