From 14992d4384990d40f6d3cfb799780fb696d77762 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Fri, 27 Jul 2018 12:05:00 -0400 Subject: make pthread_attr_init honor defaults set by pthread_setattr_default_np this fixes a major gap in the intended functionality of pthread_setattr_default_np. if application/library code creating a thread does not pass a null attribute pointer to pthread_create, but sets up an attribute object to change other properties while leaving the stack alone, the created thread will get a stack with size DEFAULT_STACK_SIZE. this makes pthread_setattr_default_np useless for working around stack overflow issues in such applications, and leaves a major risk of regression if previously-working code switches from using a null attribute pointer to an attribute object. this change aligns the behavior more closely with the glibc pthread_setattr_default_np functionality too, albeit via a different mechanism. glibc encodes "default" specially in the attribute object and reads the actual default at thread creation time. with this commit, we now copy the current default into the attribute object at pthread_attr_init time, so that applications that query the properties of the attribute object will see the right values. --- src/thread/default_attr.c | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/thread/default_attr.c (limited to 'src/thread/default_attr.c') diff --git a/src/thread/default_attr.c b/src/thread/default_attr.c new file mode 100644 index 00000000..46fe98ee --- /dev/null +++ b/src/thread/default_attr.c @@ -0,0 +1,4 @@ +#include "pthread_impl.h" + +size_t __default_stacksize = DEFAULT_STACK_SIZE; +size_t __default_guardsize = DEFAULT_GUARD_SIZE; -- cgit v1.2.1