blob: 1fefd086f7241209670ac3c7f821517a08fd1638 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
Index: thread_pthread.c
===================================================================
--- thread_pthread.c (revision 50315)
+++ thread_pthread.c (revision 50316)
@@ -662,11 +662,16 @@
# endif
struct rlimit rl;
volatile char buf[0x100];
+ enum {stack_check_margin = 0x1000}; /* for -fstack-check */
+
STACK_GROW_DIR_DETECTION;
if (!getrlimit(RLIMIT_STACK, &rl) && rl.rlim_cur == RLIM_INFINITY)
return;
+ if (size < stack_check_margin) return;
+ size -= stack_check_margin;
+
size -= sizeof(buf); /* margin */
if (IS_STACK_DIR_UPPER()) {
const volatile char *end = buf + sizeof(buf);
@@ -674,13 +679,14 @@
if (limit > end) {
size = limit - end;
limit = alloca(size);
- limit[size-1] = 0;
+ limit[stack_check_margin+size-1] = 0;
}
}
else {
limit -= size;
if (buf > limit) {
limit = alloca(buf - limit);
+ limit -= stack_check_margin;
limit[0] = 0;
}
}
|