Skip to content

Commit 3faba81

Browse files
committed
---
yaml --- r: 6604 b: refs/heads/master c: 9656cea h: refs/heads/master v: v3
1 parent 89812f9 commit 3faba81

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 5d1a1dc4203f8ae77e2e9c5cba393887f0b7d762
2+
refs/heads/master: 9656ceac60258c4189c31b402def67039ae17822

trunk/src/rt/rust_task.cpp

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

1515
#include "globals.h"
1616

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

2431
#ifdef __x86_64__
25-
#define RED_ZONE_SIZE 65536
32+
#define RED_ZONE_SIZE (65536 + STACK_NOACCESS_SIZE)
2633
#endif
2734

2835
// Stack size
@@ -56,6 +63,9 @@ new_stk(rust_scheduler *sched, rust_task *task, size_t minsz)
5663
stk->valgrind_id =
5764
VALGRIND_STACK_REGISTER(&stk->data[0],
5865
&stk->data[minsz + RED_ZONE_SIZE]);
66+
#ifndef NVALGRIND
67+
VALGRIND_MAKE_MEM_NOACCESS(stk->data, STACK_NOACCESS_SIZE);
68+
#endif
5969
task->stk = stk;
6070
return stk;
6171
}
@@ -67,6 +77,9 @@ del_stk(rust_task *task, stk_seg *stk)
6777

6878
task->stk = stk->next;
6979

80+
#ifndef NVALGRIND
81+
VALGRIND_MAKE_MEM_DEFINED(stk->data, STACK_NOACCESS_SIZE);
82+
#endif
7083
VALGRIND_STACK_DEREGISTER(stk->valgrind_id);
7184
LOGPTR(task->sched, "freeing stk segment", (uintptr_t)stk);
7285
task->free(stk);

0 commit comments

Comments
 (0)