You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.6 KiB

  1. This patch increases the stack size for pthreads from 80 KB, the default
  2. stack size for musl libc, to 2 MB. The default stack size for glibc is 8 MB.
  3. OpenDKIM, an application that depends on libmilter, segfaults if the stack
  4. size for pthreads is left unchanged at the musl default value of 80 KB.
  5. Apparently, OpenDKIM allocates blocks of 64 KB multiple times, which causes
  6. libmilter and therefore OpenDKIM to crash:
  7. https://git.alpinelinux.org/cgit/aports/commit/?id=95724d1bd53ae87f72e6388cb7323dbd8f84be9d
  8. This patch follows the patch suggested by an Alpine Linux user in bug report
  9. above. Also, a bug report has been filed upstream:
  10. https://sourceforge.net/p/opendkim/bugs/258/
  11. --- a/libmilter/libmilter.h
  12. +++ b/libmilter/libmilter.h
  13. @@ -127,10 +127,10 @@ struct smfi_str
  14. # define MI_SOCK_READ(s, b, l) read(s, b, l)
  15. # define MI_SOCK_READ_FAIL(x) ((x) < 0)
  16. # define MI_SOCK_WRITE(s, b, l) write(s, b, l)
  17. -
  18. -# define thread_create(ptid,wr,arg) pthread_create(ptid, NULL, wr, arg)
  19. # define sthread_get_id() pthread_self()
  20. +extern int thread_create(pthread_t *ptid, void *(*wr) (void *), void *arg);
  21. +
  22. typedef pthread_mutex_t smutex_t;
  23. # define smutex_init(mp) (pthread_mutex_init(mp, NULL) == 0)
  24. # define smutex_destroy(mp) (pthread_mutex_destroy(mp) == 0)
  25. --- a/libmilter/main.c
  26. +++ b/libmilter/main.c
  27. @@ -16,6 +16,12 @@ SM_RCSID("@(#)$Id: main.c,v 8.85 2013-11
  28. #include <fcntl.h>
  29. #include <sys/stat.h>
  30. +int thread_create(pthread_t *ptid, void *(*wr) (void *), void *arg) {
  31. + pthread_attr_t attr;
  32. + pthread_attr_init(&attr);
  33. + pthread_attr_setstacksize(&attr,2*1024*1024);
  34. + return pthread_create(ptid, &attr, wr, arg);
  35. +}
  36. static smfiDesc_ptr smfi = NULL;