changeset 1773:aa0db78e67c4

[xemacs-hg @ 2003-11-01 14:54:53 by kaltenbach] Bugfix in USE_KKCC mode processing weak data structures 2003-11-01 Markus Kaltenbach <makalten@informatik.uni-tuebingen.de> * src/alloc.c (garbage_collect_1):fix bug * automated/weak-tests.el:added test to track it down
author kaltenbach
date Sat, 01 Nov 2003 14:55:00 +0000
parents c6b9198bfc23
children e4f13e996732
files src/ChangeLog src/alloc.c tests/ChangeLog tests/automated/weak-tests.el
diffstat 4 files changed, 47 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Fri Oct 31 22:51:31 2003 +0000
+++ b/src/ChangeLog	Sat Nov 01 14:55:00 2003 +0000
@@ -1,3 +1,11 @@
+2003-11-01  Markus Kaltenbach  <makalten@informatik.uni-tuebingen.de>
+
+	* alloc.c (garbage_collect_1):
+	move kkcc_marking() call inside the while loop containing all
+	the iterative calls for marking weak data structures since the
+	entries on the kkcc_stack need to be processed after every run
+	to mark attached objects
+	
 2003-10-16  Jerry James  <james@xemacs.org>
 
 	* realpath.c (qxe_realpath): When a symbolic link to an absolute
--- a/src/alloc.c	Fri Oct 31 22:51:31 2003 +0000
+++ b/src/alloc.c	Sat Nov 01 14:55:00 2003 +0000
@@ -4613,10 +4613,12 @@
   while (finish_marking_weak_hash_tables () > 0 ||
 	 finish_marking_weak_lists       () > 0 ||
 	 continue_marking_ephemerons     () > 0)
+#ifdef USE_KKCC
+    {
+      kkcc_marking ();
+    }
+#else /* NOT USE_KKCC */
     ;
-
-#ifdef USE_KKCC
-  kkcc_marking ();
 #endif /* USE_KKCC */
 
   /* At this point, we know which objects need to be finalized: we
@@ -4625,12 +4627,14 @@
   while (finish_marking_ephemerons       () > 0 ||
 	 finish_marking_weak_lists       () > 0 ||
 	 finish_marking_weak_hash_tables () > 0)
-    ;
-
 #ifdef USE_KKCC
-  kkcc_marking ();
+    {
+      kkcc_marking ();
+    }
   kkcc_gc_stack_free ();
 #undef mark_object
+#else /* NOT USE_KKCC */
+    ;
 #endif /* USE_KKCC */
 
   /* And prune (this needs to be called after everything else has been
--- a/tests/ChangeLog	Fri Oct 31 22:51:31 2003 +0000
+++ b/tests/ChangeLog	Sat Nov 01 14:55:00 2003 +0000
@@ -1,3 +1,9 @@
+2003-11-01  Markus Kaltenbach  <makalten@informatik.uni-tuebingen.de>
+
+	* automated/weak-tests.el:
+	Added testing of the iterative marking calls needed for processing
+	weak data structures, especially ephemerons, correctly
+
 2003-10-22  Vin Shelton  <acs@xemacs.org>
 
 	* automated/hash-table-tests.el: Remove debugging print
--- a/tests/automated/weak-tests.el	Fri Oct 31 22:51:31 2003 +0000
+++ b/tests/automated/weak-tests.el	Sat Nov 01 14:55:00 2003 +0000
@@ -222,3 +222,26 @@
   (Assert (equal (weak-list-list weaklist4) testlist)))
 
 (garbage-collect)
+
+;; test the intended functionality of the fixpoint iteration used for marking
+;; weak data structures like the ephermerons. Basically this tests gc_internals
+;; to work properly but it also ensures the ephemerons behave according to the
+;; specification
+
+(let* ((inner_cons (cons 1 2))
+       (weak1 (make-ephemeron inner_cons
+			      (make-ephemeron inner_cons
+					      (cons 1 2)
+					      '(lambda (v) t))
+			      '(lambda (v) t))))
+  (Assert (ephemeron-ref (ephemeron-ref weak1)))
+  (garbage-collect)
+  ;; assure the inner ephis are still there
+  (Assert (ephemeron-ref (ephemeron-ref weak1)))
+  ;; delete the key reference and force cleaning up the garbage
+  (setq inner_cons (cons 3 4))
+  (garbage-collect)
+  (Assert (not (ephemeron-ref weak1)))
+)
+
+(garbage-collect)