[kaffe] CVS kaffe (dalibor): Fixed freelist corruption when gc_block array is moved

Kaffe CVS cvs-commits at kaffe.org
Thu Sep 16 16:23:47 PDT 2004


PatchSet 5176 
Date: 2004/09/16 23:19:23
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Fixed freelist corruption when gc_block array is moved

2004-09-16  Noa Resare  <noa at resare.com>

        * kaffe/kaffevm/kaffe-gc/gc-mem.c (gc_block_alloc):
        Fix freelist corruption when the gc_block array is moved.

Members: 
	ChangeLog:1.2731->1.2732 
	kaffe/kaffevm/kaffe-gc/gc-mem.c:1.14->1.15 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2731 kaffe/ChangeLog:1.2732
--- kaffe/ChangeLog:1.2731	Thu Sep 16 21:01:49 2004
+++ kaffe/ChangeLog	Thu Sep 16 23:19:23 2004
@@ -1,3 +1,8 @@
+2004-09-16  Noa Resare  <noa at resare.com>
+
+	* kaffe/kaffevm/kaffe-gc/gc-mem.c (gc_block_alloc):
+        Fix freelist corruption when the gc_block array is moved.
+
 2004-09-16  Dalibor Topic  <robilad at kaffe.org>
 
         * configure.ac:
Index: kaffe/kaffe/kaffevm/kaffe-gc/gc-mem.c
diff -u kaffe/kaffe/kaffevm/kaffe-gc/gc-mem.c:1.14 kaffe/kaffe/kaffevm/kaffe-gc/gc-mem.c:1.15
--- kaffe/kaffe/kaffevm/kaffe-gc/gc-mem.c:1.14	Fri Sep  3 19:08:20 2004
+++ kaffe/kaffe/kaffevm/kaffe-gc/gc-mem.c	Thu Sep 16 23:19:26 2004
@@ -1039,6 +1039,19 @@
 #endif
 
 /*
+ * Determine if ptr points inside the array of gc_block structures.
+ *
+ * @param ptr the pointer to check for
+ * @param base a pointer to the start of the array
+ * @param count the number of elements in the array
+ */
+static int
+inside(void* ptr, gc_block* base, int count) {
+        return ((gc_block*)ptr >= base && (gc_block*)ptr < base + count);
+}
+
+
+/*
  * Allocate size bytes of heap memory, and return the corresponding
  * gc_block *.
  */
@@ -1132,6 +1145,8 @@
 			    R(b[i].next);
 			    R(b[i].pprev);
 			    R(b[i].pnext);
+                            if (inside(b[i].free, (gc_block*)old_blocks, onb))
+				R(b[i].free);
 			  }
 
 			memset(b + onb, 0,




More information about the kaffe mailing list