[Bug libgcj/13212] JNI/CNI AttachCurrentThread does not register thread with garbage collector

2005-10-07 Thread stewart at neuron dot com


--- Comment #10 from stewart at neuron dot com  2005-10-07 13:49 ---
(In reply to comment #9)
> Yes, I'm sure. I know what's going on here.
> 

This is the only bug I was able to find regarding AttachCurrentThread.  I'm
working on getting FUSE-J (Java bindings for FUSE userspace filesystem) working
with GCJ and have run across an apparent bug with
AttachCurrentThread/AttachCurrentThreadAsDaemon whereby the returned JNIEnv has
a corrupted pointer to CallObjectMethod.  I emailed the following to :

You should be able to setup/reproduce this quickly.  First is to
get/build/install the fuse library:

http://fuse.sourceforge.net/
http://easynews.dl.sourceforge.net/sourceforge/fuse/fuse-2.4.0.tar.gz

./configure --prefix=/usr/local &&
make &&
make install &&
depmod -a &&
modprobe fuse

Second, get fuse-j, the java language bindings

http://www.select-tech.si/fuse/
http://www.select-tech.si/fuse/fuse-j-2.2.3.tar.gz

get and apply my patch for gcj:

http://mrallen.com/misc/fuse-j-2.2.3-gcj.diff

inside fuse-j-2.2.3:

patch -p1 < path_to_patch

then you will need a zip file to test and a mount point. next:

make
sh zipfs_gcj.sh  

once it's running, doing a 'df' in another term will crash cause the segfault. 
you will have to have /usr/local/bin in your PATH and execute 'fusermount -u
' to undo the mount. (In reply to comment #9)
> Yes, I'm sure. I know what's going on here.
> 


-- 

stewart at neuron dot com changed:

   What|Removed |Added
--------------------
 CC||stewart at neuron dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13212



[Bug libgcj/13212] JNI/CNI AttachCurrentThread does not register thread with garbage collector

2005-10-12 Thread stewart at neuron dot com


--- 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 - 1.95.2.2
+++ jni.cc 12 Oct 2005 18:50:20 -
@@ -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 (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