diff options
author | Stefan Wagner <stw@bit-strickerei.de> | 2016-11-06 23:10:10 +0100 |
---|---|---|
committer | Jakub Jirutka <jakub@jirutka.cz> | 2016-11-07 00:53:41 +0100 |
commit | 95724d1bd53ae87f72e6388cb7323dbd8f84be9d (patch) | |
tree | 4b55ad2f447b12d7dfd5c352061608b2e9322e36 /testing/libmilter/default-pthread-stacksize.patch | |
parent | 104da5ebb5da1487cbcb565509b90636b7fe0702 (diff) | |
download | aports-95724d1bd53ae87f72e6388cb7323dbd8f84be9d.tar.bz2 aports-95724d1bd53ae87f72e6388cb7323dbd8f84be9d.tar.xz |
testing/libmilter: set default pthread stack size to 8 MB
This patch tries to fix various crashes for applications depending on
libmilter by setting the stack size for pthreads to 8 MB. The default
stack size for musl libc is set to 80 KB whereas glibc has it set
to 8 MB. This causes problems when a large amount of memory is
allocated on the stack.
For example, opendkim allocates blocks of 64 KB multiple times, which
causes libmilter (and therefore opendkim) to crash.
Maybe a stack size of 1 MB or 2 MB would be sufficient, but as opendkim
depends on the default glibc behavior, 8 MB should be safe.
I know this patch is kind of ugly, a better solution may be to file
a request for opendkim to allocate large blocks of memory on the heap.
But as libmilter/opendkim are fairly unusable at the moment, I suggest
to apply this patch as long as these packages are in testing.
Fixes https://bugs.alpinelinux.org/issues/6360
Diffstat (limited to 'testing/libmilter/default-pthread-stacksize.patch')
-rw-r--r-- | testing/libmilter/default-pthread-stacksize.patch | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/testing/libmilter/default-pthread-stacksize.patch b/testing/libmilter/default-pthread-stacksize.patch new file mode 100644 index 0000000000..4e3524c230 --- /dev/null +++ b/testing/libmilter/default-pthread-stacksize.patch @@ -0,0 +1,44 @@ +Set default pthread stack size to 8 MB + +This patch tries to fix various crashes for applications depending on +libmilter by setting the stack size for pthreads to 8 MB. The default +stack size for musl libc is set to 80 KB whereas glibc has it set +to 8 MB. This causes problems when a large amount of memory is +allocated on the stack. + +For example, opendkim allocates blocks of 64 KB multiple times, which +causes libmilter (and therefore opendkim) to crash. +Maybe a stack size of 1 MB or 2 MB would be sufficient, but as opendkim +depends on the default glibc behavior, 8 MB should be safe. + +Fixes https://bugs.alpinelinux.org/issues/6360 + +--- a/libmilter/libmilter.h ++++ b/libmilter/libmilter.h +@@ -127,10 +127,10 @@ + # define MI_SOCK_READ(s, b, l) read(s, b, l) + # define MI_SOCK_READ_FAIL(x) ((x) < 0) + # define MI_SOCK_WRITE(s, b, l) write(s, b, l) +- +-# define thread_create(ptid,wr,arg) pthread_create(ptid, NULL, wr, arg) + # define sthread_get_id() pthread_self() + ++extern int thread_create(pthread_t *ptid, void *(*wr) (void *), void *arg); ++ + typedef pthread_mutex_t smutex_t; + # define smutex_init(mp) (pthread_mutex_init(mp, NULL) == 0) + # define smutex_destroy(mp) (pthread_mutex_destroy(mp) == 0) +--- a/libmilter/main.c ++++ b/libmilter/main.c +@@ -16,6 +16,12 @@ + #include <fcntl.h> + #include <sys/stat.h> + ++int thread_create(pthread_t *ptid, void *(*wr) (void *), void *arg) { ++ pthread_attr_t attr; ++ pthread_attr_init(&attr); ++ pthread_attr_setstacksize(&attr,8*1024*1024); ++ return pthread_create(ptid, &attr, wr, arg); ++} + + static smfiDesc_ptr smfi = NULL; |