summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--lib.c6
-rw-r--r--lib.h3
3 files changed, 22 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 12d02a11..2f51b4c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2009-11-25 Kaz Kylheku <kkylheku@gmail.com>
+ More valgrind integration. Vector objects keep displaced pointers
+ to vector data; they point to element 0 which is actually the third
+ element of the vector. If an object is only referenced by interior
+ pointers, Valgrind reports it as possibly leaked. This change
+ conditionally adds a pointer to the true start of the vector,
+ if Valgrind support is enabled.
+
+ * lib.h (struct vec): vec_true_start, new member.
+
+ * lib.c (vector, vec_set_fill): Maintain vec_true_start.
+
+2009-11-25 Kaz Kylheku <kkylheku@gmail.com>
+
First stab at Valgrind integration. First goal: eliminate false
positives when gc is accessing uninitialized parts of the stack.
diff --git a/lib.c b/lib.c
index 66622407..ba484ed7 100644
--- a/lib.c
+++ b/lib.c
@@ -1378,6 +1378,9 @@ val vector(val alloc)
val *v = (val *) chk_malloc(alloc_plus * sizeof *v);
vec->v.type = VEC;
vec->v.vec = v + 2;
+#ifdef HAVE_VALGRIND
+ vec->v.vec_true_start = v;
+#endif
v[0] = alloc;
v[1] = zero;
return vec;
@@ -1406,6 +1409,9 @@ val vec_set_fill(val vec, val fill)
(new_alloc + 2)*sizeof *newvec);
vec->v.vec = newvec + 2;
vec->v.vec[vec_alloc] = num(new_alloc);
+#ifdef HAVE_VALGRIND
+ vec->v.vec_true_start = newvec;
+#endif
}
if (fill_delta > 0) {
diff --git a/lib.h b/lib.h
index b8948351..5f0df256 100644
--- a/lib.h
+++ b/lib.h
@@ -108,6 +108,9 @@ struct vec {
/* vec[-2] is allocated size */
/* vec[-1] is fill pointer */
val *vec;
+#ifdef HAVE_VALGRIND
+ val *vec_true_start;
+#endif
};
/*