On tor, 2004-09-16 at 11:29 +0200, Guilhem Lavaux wrote:
>
> The problems is that the "free" field has two meanings. Either a pointer
> on the next element pointer of the former one (followed ? :) ) either a
> direct entry point in the free list of the small blocks. Maybe the two
> lists are messed up at that point. As you suggest we may set "free" to
> NULL in gc_remove_from_primfreelist, it will ease the debugging a bit
> and keep the list consistent. In the case of small blocks, I think you
> may clear free just before gc_primitive_free. If you find some other
> places feel free to do it.
>
> Meanwhile, I'll look at the freelist management ... again... ;)
>
I have found the problem now. What I didn't notice at first was the
relocation of the gc_block array that realloc() sometimes preforms. It
doesn't take into account when gc_block->free holds a pointer into the
old array. The attached patch fixes that.
Please apply.
/noa
--
And the lions ate the christians and the christians burned the witches,
and even I am out of explanations -- Ola Salo
gpg fingerprint: F3C4 AC90 B885 FE15 344B 4D05 220B 7662 A190 6F09
Index: ChangeLog
===================================================================
RCS file: /cvs/kaffe/kaffe/ChangeLog,v
retrieving revision 1.2730
diff -u -r1.2730 ChangeLog
--- ChangeLog 16 Sep 2004 15:49:15 -0000 1.2730
+++ ChangeLog 16 Sep 2004 19:22:34 -0000
@@ -1,3 +1,8 @@
+2004-09-16 Noa Resare <[EMAIL PROTECTED]>
+
+ * 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 <[EMAIL PROTECTED]>
* libraries/javalib/java/awt/Component.java (postEvent):
Index: kaffe/kaffevm/kaffe-gc/gc-mem.c
===================================================================
RCS file: /cvs/kaffe/kaffe/kaffe/kaffevm/kaffe-gc/gc-mem.c,v
retrieving revision 1.14
diff -u -r1.14 gc-mem.c
--- kaffe/kaffevm/kaffe-gc/gc-mem.c 3 Sep 2004 19:08:20 -0000 1.14
+++ kaffe/kaffevm/kaffe-gc/gc-mem.c 16 Sep 2004 19:22:36 -0000
@@ -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,
_______________________________________________
kaffe mailing list
[EMAIL PROTECTED]
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe