ons 2004-10-20 klockan 18:47 +0200 skrev Guilhem Lavaux:
> 
> I've just commited it. Please test it extensively. I would like also a 
> thread hog test to see if there are memory leaks with the new scheme.
> 
> Cheers,
> 
> Guilhem.


I have now tested the new code a bit. I have succeeded to hang it once
after about 5 hours of testing (but that could be related to the problem
below) but it is much more stable than any other kaffe version I have
tested.

I have however found out empirically that KGC_rmRef() in tDispose()
somehow uses the thread local kSem, so KaffeVM_unlinkNativeAndJavaThread
(which calls ksemDestroy) needs to be invoked after that, not before.
Applying the attached patch fixes fairly frequent lockups with Fedora
Core 2.92 (it takes about a minute to reproduce the lockup).

However, I'm not sure how this will work if MAX_CACHED_THREADS is
defined to something else than 0 in the future, as I get the impression
that the thread local ksem is initialized on reused threads also, not
only on newly created threads. That would lead to multiple calls to
ksemInit on the same ksem structure. 

Random thoughts: 

- in unlinkNativeAndJavaThread(), the only unlinking that takes place
seems to be that the jniEnv member is set to 0. Since this is the last
time (?) the thread_data structure is ever accessed the value of jniEnv
shouldn't matter to anyone. Therefore the name unlinkNativeAndJavaThread
is not only ugly but also misleading :P

- since the thread local ksem seems to be used by a variety of seemingly
unrelated code (locking, the gc interface) It is important that it is
initialized as early as possible and destroyed as late as possible in a
thread's life cycle. It is also important that this is only called for
new and not for reused threads (not that we have any atm).

Thanks a lot for your work.

/noa
Index: ChangeLog
===================================================================
RCS file: /cvs/kaffe/kaffe/ChangeLog,v
retrieving revision 1.2875
diff -u -r1.2875 ChangeLog
--- ChangeLog	21 Oct 2004 21:08:45 -0000	1.2875
+++ ChangeLog	22 Oct 2004 10:29:49 -0000
@@ -1,3 +1,8 @@
+2004-10-22  Noa Resare  <[EMAIL PROTECTED]>
+
+	* kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:
+	Move KaffeVM_unlinkNativeAndJavaThread() to after KGC_rmRef()
+
 2004-10-21  Dalibor Topic  <[EMAIL PROTECTED]>
 
 	* kaffe/kaffevm/gc.h:
Index: kaffe/kaffevm/systems/unix-pthreads/thread-impl.c
===================================================================
RCS file: /cvs/kaffe/kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c,v
retrieving revision 1.49
diff -u -r1.49 thread-impl.c
--- kaffe/kaffevm/systems/unix-pthreads/thread-impl.c	20 Oct 2004 16:47:14 -0000	1.49
+++ kaffe/kaffevm/systems/unix-pthreads/thread-impl.c	22 Oct 2004 10:29:50 -0000
@@ -732,8 +732,6 @@
 
 	unprotectThreadList(cur);
 
-	/* we are done using locks now. ok to destroy ksem */
-	KaffeVM_unlinkNativeAndJavaThread();
 
 	if ( nCached >= MAX_CACHED_THREADS ){
 	  break;
@@ -919,6 +917,7 @@
 {
   /* Remove the static reference so the thread context may be freed. */
   KGC_rmRef(threadCollector, nt);
+  KaffeVM_unlinkNativeAndJavaThread();
 
   pthread_detach( nt->tid);
   pthread_mutex_destroy (&nt->suspendLock);
_______________________________________________
kaffe mailing list
[EMAIL PROTECTED]
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to