store pthread stack guard sizes for pthread_getattr_np
authorWilliam Pitcock <nenolod@dereferenced.org>
Fri, 2 Feb 2018 20:08:55 +0000 (20:08 +0000)
committerRich Felker <dalias@aerifal.cx>
Sat, 3 Feb 2018 15:04:24 +0000 (10:04 -0500)
src/internal/pthread_impl.h
src/thread/pthread_create.c
src/thread/pthread_getattr_np.c

index f0b2c20ca2ed4cd80ec5c6443fb3aa070baeb95c..4a0db987c6a7ea857142a29dc595f5bed35dc5b7 100644 (file)
@@ -46,6 +46,7 @@ struct pthread {
        char *dlerror_buf;
        int dlerror_flag;
        void *stdio_locks;
+       size_t guard_size;
        uintptr_t canary_at_end;
        void **dtv_copy;
 };
index 34cd9936b1c037828daf48dfc4bd84895f822cd5..439ee3633ebaaa7b7f7b4cc964b63a9dafa3012a 100644 (file)
@@ -232,8 +232,8 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att
                        memset(stack, 0, need);
                } else {
                        size = ROUND(need);
-                       guard = 0;
                }
+               guard = 0;
        } else {
                guard = ROUND(attr._a_guardsize);
                size = guard + ROUND(attr._a_stacksize
@@ -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;
index ae26a5aba686d6f8d880162e9c0fe77de7f391b9..29a209bd975894b758356beb2085d8cb68ffb58e 100644 (file)
@@ -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;