about summary refs log tree commit diff
path: root/src/rt/rust_task.cpp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-12-06 17:19:24 -0800
committerBrian Anderson <banderson@mozilla.com>2011-12-06 22:35:42 -0800
commit9656ceac60258c4189c31b402def67039ae17822 (patch)
tree6cf5ebf7665d5bdcbaac271c0c747fd05bc90389 /src/rt/rust_task.cpp
parent5d1a1dc4203f8ae77e2e9c5cba393887f0b7d762 (diff)
downloadrust-9656ceac60258c4189c31b402def67039ae17822.tar.gz
rust-9656ceac60258c4189c31b402def67039ae17822.zip
rt: Put 16 guard bytes at the end of the stack
Diffstat (limited to 'src/rt/rust_task.cpp')
-rw-r--r--src/rt/rust_task.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index 0f97a0a6853..bdc2f7ff7ce 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -14,15 +14,22 @@
 
 #include "globals.h"
 
+// Each stack gets some guard bytes that valgrind will verify we don't touch
+#ifndef NVALGRIND
+#define STACK_NOACCESS_SIZE 16
+#else
+#define STACK_NOACCESS_SIZE 0
+#endif
+
 // The amount of extra space at the end of each stack segment, available
 // to the rt, compiler and dynamic linker for running small functions
 // FIXME: We want this to be 128 but need to slim the red zone calls down
 #ifdef __i386__
-#define RED_ZONE_SIZE 65536
+#define RED_ZONE_SIZE (65536 + STACK_NOACCESS_SIZE)
 #endif
 
 #ifdef __x86_64__
-#define RED_ZONE_SIZE 65536
+#define RED_ZONE_SIZE (65536 + STACK_NOACCESS_SIZE)
 #endif
 
 // Stack size
@@ -56,6 +63,9 @@ new_stk(rust_scheduler *sched, rust_task *task, size_t minsz)
     stk->valgrind_id =
         VALGRIND_STACK_REGISTER(&stk->data[0],
                                 &stk->data[minsz + RED_ZONE_SIZE]);
+#ifndef NVALGRIND
+    VALGRIND_MAKE_MEM_NOACCESS(stk->data, STACK_NOACCESS_SIZE);
+#endif
     task->stk = stk;
     return stk;
 }
@@ -67,6 +77,9 @@ del_stk(rust_task *task, stk_seg *stk)
 
     task->stk = stk->next;
 
+#ifndef NVALGRIND
+    VALGRIND_MAKE_MEM_DEFINED(stk->data, STACK_NOACCESS_SIZE);
+#endif
     VALGRIND_STACK_DEREGISTER(stk->valgrind_id);
     LOGPTR(task->sched, "freeing stk segment", (uintptr_t)stk);
     task->free(stk);