[kaffe] CVS kaffe (guilhem): Fix for *Ref object.

Kaffe CVS cvs-commits at kaffe.org
Fri Mar 11 08:56:36 PST 2005


PatchSet 5517 
Date: 2005/03/11 16:48:47
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Fix for *Ref object.

	* kaffe/kaffevm/reference.c
	(referenceObjectFinalizer): Really remove the object from the
	hash and free it.
	(referenceFinalizer): If the entry has already been freed just
	finalize the object.

	Reported by Michael Koch <konqueror at gmx.de>

Members: 
	ChangeLog:1.3691->1.3692 
	kaffe/kaffevm/reference.c:1.3->1.4 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3691 kaffe/ChangeLog:1.3692
--- kaffe/ChangeLog:1.3691	Fri Mar 11 16:45:29 2005
+++ kaffe/ChangeLog	Fri Mar 11 16:48:47 2005
@@ -1,3 +1,13 @@
+2005-05-11  Guilhem Lavaux  <guilhem at kaffe.org>
+
+	* kaffe/kaffevm/reference.c
+	(referenceObjectFinalizer): Really remove the object from the
+	hash and free it.
+	(referenceFinalizer): If the entry has already been freed just
+	finalize the object.
+
+	Reported by Michael Koch <konqueror at gmx.de>
+
 2005-05-11  Guilhem Lavaux  <guilhem at kaffe.org>,
 	Helmer Krämer <hkraemer at freenet.de>
 
Index: kaffe/kaffe/kaffevm/reference.c
diff -u kaffe/kaffe/kaffevm/reference.c:1.3 kaffe/kaffe/kaffevm/reference.c:1.4
--- kaffe/kaffe/kaffevm/reference.c:1.3	Fri Mar 11 16:41:53 2005
+++ kaffe/kaffe/kaffevm/reference.c	Fri Mar 11 16:48:51 2005
@@ -160,7 +160,7 @@
   lockStaticMutex(&referencesLock);
   search_ref.obj = ob;
   head = (referenceLinkListHead *)hashFind(referencesHashTable, &search_ref);
-  hashRemove(referencesHashTable, &search_ref);
+  hashRemove(referencesHashTable, head);
   unlockStaticMutex(&referencesLock);
   
   assert(head != NULL);
@@ -192,6 +192,7 @@
       KFREE(ll);
       ll = temp;
     }
+  KFREE(head);
   defaultObjectFinalizer(ob);
 }
 
@@ -214,7 +215,13 @@
   lockStaticMutex(&referencesLock);
   search_ref.obj = referent;
   head = (referenceLinkListHead *)hashFind(referencesHashTable, &search_ref);
-  assert(head != NULL);
+  /* The object has already been finalized though the reference is still here. */
+  if (head == NULL)
+  {
+     unlockStaticMutex(&referencesLock);
+     defaultObjectFinalizer(ref);
+     return;
+  }
 
   ll = &head->references;
   while (*ll != NULL)




More information about the kaffe mailing list