Valgrind support for Ruby

Posted at 2005-09-16

Debugging Ruby extensions with Valgrind is a tedious task, because Valgrind doesn't like Ruby's garbage collector much. Valgrind will print a lot of errors and warnings, which are mostly bogus. This makes it hard to spot the real errors you're looking for.

One way to deal with this is to create a suppression file for Valgrind. Suppression files are used to tell Valgrind to ignore certain errors. For every bogus error, the suppression file has to be extended. Although Valgrind can generate suppression files itself, and I've spend some time on generating a suppression file, I never got a perfect one which made Valgrind shut up about Ruby.

So I wrote a patch for Ruby that tells Valgrind that the memory locations the GC uses are safe to read, which makes it stop bitching about all those bogus errors. The patch is tiny, yet efficient:  |    4 ++-- |   14 ++++++++++++++
gc.c         |   12 ++++++++++++
3 files changed, 28 insertions(+), 2 deletions(-)


I prepared an updated patch.