Skip to content

Commit fe683df

Browse files
committed
rt: Get rid of the valgrind guard bytes at the end of the stack
Preventing us from writing beyond our allocations is _what valgrind does_, so telling valgrind not to let us write to the end of the stack isn't buying anything.
1 parent 00be346 commit fe683df

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

src/rt/rust_task.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,15 @@
1515

1616
#include "globals.h"
1717

18-
// Each stack gets some guard bytes that valgrind will verify we don't touch
19-
#ifndef NVALGRIND
20-
#define STACK_NOACCESS_SIZE 16
21-
#else
22-
#define STACK_NOACCESS_SIZE 0
23-
#endif
24-
2518
// The amount of extra space at the end of each stack segment, available
2619
// to the rt, compiler and dynamic linker for running small functions
2720
// FIXME: We want this to be 128 but need to slim the red zone calls down
2821
#ifdef __i386__
29-
#define RED_ZONE_SIZE (65536 + STACK_NOACCESS_SIZE)
22+
#define RED_ZONE_SIZE 65536
3023
#endif
3124

3225
#ifdef __x86_64__
33-
#define RED_ZONE_SIZE (65536 + STACK_NOACCESS_SIZE)
26+
#define RED_ZONE_SIZE 65536
3427
#endif
3528

3629
// Stack size
@@ -80,19 +73,11 @@ config_valgrind_stack(stk_seg *stk) {
8073
// caused valgrind to consider the whole thing inaccessible.
8174
size_t sz = stk->end - (uintptr_t)&stk->data[0];
8275
VALGRIND_MAKE_MEM_UNDEFINED(stk->data, sz);
83-
84-
// Establish some guard bytes so valgrind will tell
85-
// us if we run off the end of the stack
86-
VALGRIND_MAKE_MEM_NOACCESS(stk->data, STACK_NOACCESS_SIZE);
8776
#endif
8877
}
8978

9079
static void
9180
unconfig_valgrind_stack(stk_seg *stk) {
92-
#ifndef NVALGRIND
93-
// Make the guard bytes accessible again, but undefined
94-
VALGRIND_MAKE_MEM_UNDEFINED(stk->data, STACK_NOACCESS_SIZE);
95-
#endif
9681
VALGRIND_STACK_DEREGISTER(stk->valgrind_id);
9782
}
9883

0 commit comments

Comments
 (0)