Permalink
Browse files

Ensure that we tell Valgrind about our fiber stacks

This makes sure that valgrind can properly check whether we overflow or
underflow our stacks. Without this it will wrongly complain about
accessing stuff outside the stack in fibers.
  • Loading branch information...
dbussink committed Sep 21, 2012
1 parent 1d2e229 commit bb09356d621ebd195d203334f9e68c61cacac621
Showing with 16 additions and 0 deletions.
  1. +4 −0 configure
  2. +9 −0 vm/fiber_stack.cpp
  3. +3 −0 vm/fiber_stack.hpp
View
@@ -1164,6 +1164,10 @@ int main() { return tgetnum(""); }
if has_header("sys/pstat.h")
@defines << "HAVE_SYS_PSTAT_H"
end
+
+ if has_header("valgrind/valgrind.h")
+ @defines << "HAVE_VALGRIND_H"
+ end
end
def process
View
@@ -9,6 +9,9 @@
#include "gc/gc.hpp"
#include <stdlib.h>
+#ifdef HAVE_VALGRIND_H
+#include <valgrind/valgrind.h>
+#endif
namespace rubinius {
@@ -22,10 +25,16 @@ namespace rubinius {
void FiberStack::allocate() {
assert(!address_);
address_ = malloc(size_);
+#ifdef HAVE_VALGRIND_H
+ valgrind_id_ = VALGRIND_STACK_REGISTER(address_, (char *)address_ + size_);
+#endif
}
void FiberStack::free() {
if(!address_) return;
+#ifdef HAVE_VALGRIND_H
+ VALGRIND_STACK_DEREGISTER(valgrind_id_);
+#endif
::free(address_);
address_ = 0;
}
View
@@ -10,6 +10,9 @@ namespace rubinius {
size_t size_;
int refs_;
FiberData* user_;
+#ifdef HAVE_VALGRIND_H
+ unsigned valgrind_id_;
+#endif
public:
FiberStack(size_t size);

0 comments on commit bb09356

Please sign in to comment.