[kaffe] Weak references/Class destruction

Guilhem Lavaux guilhem at kaffe.org
Wed Dec 22 10:19:35 PST 2004


Timothy Stack wrote:

>>Hi,
>>
>>Here is a patch which changes the way the classes are destroyed and 
>>implements
>>weak references for boehm-gc and kaffe-gc. This fixes class concurrent
>>destruction issues which was bugging boehm-gc (and maybe also kaffe-gc) and
>>should insure that we do not access already freed memory.
>>    
>>
>
>Is there a more detailed description of this problem in the mail archive?  
>Alas, I haven't been paying close enough attention, so a pointer would 
>be nice ;)...
>
>  
>
It has not been really discussed on the list but I've mentioned the 
problem in these messages:

http://www.kaffe.org/pipermail/kaffe/2004-November/100481.html
http://www.kaffe.org/pipermail/kaffe/2004-November/100487.html


You can also see the answer of Hans Boehm when I asked a question 
related to the problem in this link:

http://www.hpl.hp.com/hosted/linux/mail-archives/gc/2004-August/000522.html
http://www.hpl.hp.com/hosted/linux/mail-archives/gc/2004-August/000524.html
http://www.hpl.hp.com/hosted/linux/mail-archives/gc/2004-August/000527.html

Good reading ! ;)

>As for the patch, I'm not really clear what is going on with the weakrefs 
>yet, but the portions that deal with gc'ing tramps and translated code 
>look fine.  And, I think there is a small bug in the boehm-gc part of the 
>patch, you define an empty static version of KaffeGC_*WeakRef in gc2.c:
>
>  +static
>  +bool
>  +KaffeGC_addWeakRef(Collector *collector UNUSED, void* mem UNUSED, void **ref UNUSED)
>  +{
>  +}
>  +
>
>But there is also a real version in gc-refs.c, which might be ignored when 
>filling out the GC vtable.  Or, maybe I'm just missing something...
>
>  
>

Ooops ! You're right. I'm removing the static version now. Thanks ! :)
The weak reference functions remembers all desired pointers to pointer
of an object. When the object is destroyed KaffeGC_clearWeakRef is
called and all references to the object which has been registered are
cleared. We may introduce another mechanism at that point to advertise
the destruction of registered object through java.lang.ref.WeakReference.

Regards,

Guilhem Lavaux.




More information about the kaffe mailing list