]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix #1176: stack size too small for Alpine Linux.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 9 Dec 2016 10:09:01 +0000 (10:09 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 9 Dec 2016 10:09:01 +0000 (10:09 +0000)
git-svn-id: file:///svn/unbound/trunk@3959 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
util/locks.h

index 57a13c8c537d6b381ed08f311ca99b1b6ab65a31..47ed3027d9ef875cb269b80f1e0e279cdf7aa9d4 100644 (file)
@@ -1,5 +1,9 @@
+9 December 2016: Wouter
+       - Fix #1176: stack size too small for Alpine Linux.
+
 8 December 2016: Wouter
        - Fix downcast warnings from visual studio in sldns code.
+       - tag 1.6.0rc1
 
 7 December 2016: Ralph
        - Add DSA support for OpenSSL 1.1.0
index 3776912aaca2d6428b66c7636bb67e9c6a7b2e72..f9a9eed9eb4fbece1048f6ef7d819dcdd9a618cd 100644 (file)
@@ -149,8 +149,25 @@ typedef pthread_spinlock_t lock_quick_t;
 
 /** Thread creation */
 typedef pthread_t ub_thread_t;
-/** Pass where to store tread_t in thr. Use default NULL attributes. */
-#define ub_thread_create(thr, func, arg) LOCKRET(pthread_create(thr, NULL, func, arg))
+/** On alpine linux default thread stack size is 80 Kb. See
+http://wiki.musl-libc.org/wiki/Functional_differences_from_glibc#Thread_stack_size
+This is not enough and cause segfault. Other linux distros have 2 Mb at least.
+Wrapper for set up thread stack size */
+#define PTHREADSTACKSIZE 2*1024*1024
+#define PTHREADCREATE(thr, stackrequired, func, arg) do {\
+       pthread_attr_t attr; \
+       size_t stacksize; \
+       LOCKRET(pthread_attr_init(&attr)); \
+       LOCKRET(pthread_attr_getstacksize(&attr, &stacksize)); \
+       if (stacksize < stackrequired) { \
+               LOCKRET(pthread_attr_setstacksize(&attr, stackrequired)); \
+               LOCKRET(pthread_create(thr, &attr, func, arg)); \
+               LOCKRET(pthread_attr_getstacksize(&attr, &stacksize)); \
+               verbose(VERB_ALGO, "Thread stack size set to %zu", stacksize); \
+       } else {LOCKRET(pthread_create(thr, NULL, func, arg));} \
+       } while(0)
+/** Use wrapper for set thread stack size on attributes. */
+#define ub_thread_create(thr, func, arg) PTHREADCREATE(thr, PTHREADSTACKSIZE, func, arg)
 /** get self id. */
 #define ub_thread_self() pthread_self()
 /** wait for another thread to terminate */