blob: f132eacead0154d0ec47ea52787efd0ebfbb9b32 (
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
From 21845fbedb172de1e14946fcf4c517ebc4d12fc1 Mon Sep 17 00:00:00 2001
From: William Pitcock <nenolod@dereferenced.org>
Date: Sat, 6 Jan 2018 04:42:44 +0000
Subject: [PATCH] track pthread stack guard sizes
some applications (rustc) are dependent on pthread_getattr_np() providing the guard size.
---
src/internal/pthread_impl.h | 1 +
src/thread/pthread_create.c | 1 +
src/thread/pthread_getattr_np.c | 1 +
3 files changed, 3 insertions(+)
diff --git a/src/internal/pthread_impl.h b/src/internal/pthread_impl.h
index 56e19348..c2cafeaa 100644
--- a/src/internal/pthread_impl.h
+++ b/src/internal/pthread_impl.h
@@ -48,6 +48,7 @@ struct pthread {
void *stdio_locks;
uintptr_t canary_at_end;
void **dtv_copy;
+ size_t guard_size;
};
struct __timer {
diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c
index 6cbf85b3..0faad765 100644
--- a/src/thread/pthread_create.c
+++ b/src/thread/pthread_create.c
@@ -265,6 +265,7 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att
new->map_size = size;
new->stack = stack;
new->stack_size = stack - stack_limit;
+ new->guard_size = guard;
new->start = entry;
new->start_arg = arg;
new->self = new;
diff --git a/src/thread/pthread_getattr_np.c b/src/thread/pthread_getattr_np.c
index ae26a5ab..29a209bd 100644
--- a/src/thread/pthread_getattr_np.c
+++ b/src/thread/pthread_getattr_np.c
@@ -7,6 +7,7 @@ int pthread_getattr_np(pthread_t t, pthread_attr_t *a)
{
*a = (pthread_attr_t){0};
a->_a_detach = !!t->detached;
+ a->_a_guardsize = t->guard_size;
if (t->stack) {
a->_a_stackaddr = (uintptr_t)t->stack;
a->_a_stacksize = t->stack_size;
--
2.15.0
|