summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-19 04:34:44 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-19 04:34:44 +0000
commit1d23c250f07a3d977eb5b0c9dd4fac359dc112d2 (patch)
tree617eda2baf8bbb4f10b1543f8571f4c5a9c1eb59 /gc.c
parent0a02ad5e2e2cdd7e3dcb33f40eae056a8dfdc639 (diff)
* gc.c: use VALGRIND_MAKE_MEM_UNDEFINED to detect use of collected
objects if valgrind is available. It cannot detect first 2 words because they are used as the free list. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/gc.c b/gc.c
index f187b06820..a9683e7493 100644
--- a/gc.c
+++ b/gc.c
@@ -40,8 +40,12 @@
# ifndef VALGRIND_MAKE_MEM_DEFINED
# define VALGRIND_MAKE_MEM_DEFINED(p, n) VALGRIND_MAKE_READABLE(p, n)
# endif
+# ifndef VALGRIND_MAKE_MEM_UNDEFINED
+# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) VALGRIND_MAKE_WRITABLE(p, n)
+# endif
#else
# define VALGRIND_MAKE_MEM_DEFINED(p, n) /* empty */
+# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) /* empty */
#endif
int rb_io_fptr_finalize(struct rb_io_t*);
@@ -1099,6 +1103,7 @@ finalize_list(RVALUE *p)
RVALUE *tmp = p->as.free.next;
run_final((VALUE)p);
if (!FL_TEST(p, FL_SINGLETON)) { /* not freeing page */
+ VALGRIND_MAKE_MEM_UNDEFINED((void*)p, sizeof(RVALUE));
p->as.free.flags = 0;
p->as.free.next = freelist;
freelist = p;
@@ -1168,6 +1173,7 @@ gc_sweep(void)
final_list = p;
}
else {
+ VALGRIND_MAKE_MEM_UNDEFINED((void*)p, sizeof(RVALUE));
p->as.free.flags = 0;
p->as.free.next = freelist;
freelist = p;
@@ -1218,6 +1224,7 @@ gc_sweep(void)
void
rb_gc_force_recycle(VALUE p)
{
+ VALGRIND_MAKE_MEM_UNDEFINED((void*)p, sizeof(RVALUE));
RANY(p)->as.free.flags = 0;
RANY(p)->as.free.next = freelist;
freelist = RANY(p);
@@ -2001,10 +2008,12 @@ rb_gc_call_finalizer_at_exit(void)
else if (RANY(p)->as.data.dfree) {
(*RANY(p)->as.data.dfree)(DATA_PTR(p));
}
+ VALGRIND_MAKE_MEM_UNDEFINED((void*)p, sizeof(RVALUE));
}
else if (BUILTIN_TYPE(p) == T_FILE) {
if (rb_io_fptr_finalize(RANY(p)->as.file.fptr)) {
p->as.free.flags = 0;
+ VALGRIND_MAKE_MEM_UNDEFINED((void*)p, sizeof(RVALUE));
}
}
p++;