[kaffe] frustrating news regarding the pthread instability

Noa Resare noa at resare.com
Fri Oct 22 03:30:24 PDT 2004


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kaffe-glibc-lockup.patch
Type: text/x-patch
Size: 1394 bytes
Desc: not available
Url : http://kaffe.org/pipermail/kaffe/attachments/20041022/54cf7bef/attachment-0002.bin 


More information about the kaffe mailing list