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.

48 lines
1.9 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. Index: sendmail-8.15.2/libmilter/libmilter.h
  12. ===================================================================
  13. --- sendmail-8.15.2.orig/libmilter/libmilter.h
  14. +++ sendmail-8.15.2/libmilter/libmilter.h
  15. @@ -127,10 +127,10 @@ struct smfi_str
  16. # define MI_SOCK_READ(s, b, l) read(s, b, l)
  17. # define MI_SOCK_READ_FAIL(x) ((x) < 0)
  18. # define MI_SOCK_WRITE(s, b, l) write(s, b, l)
  19. -
  20. -# define thread_create(ptid,wr,arg) pthread_create(ptid, NULL, wr, arg)
  21. # define sthread_get_id() pthread_self()
  22. +extern int thread_create(pthread_t *ptid, void *(*wr) (void *), void *arg);
  23. +
  24. typedef pthread_mutex_t smutex_t;
  25. # define smutex_init(mp) (pthread_mutex_init(mp, NULL) == 0)
  26. # define smutex_destroy(mp) (pthread_mutex_destroy(mp) == 0)
  27. Index: sendmail-8.15.2/libmilter/main.c
  28. ===================================================================
  29. --- sendmail-8.15.2.orig/libmilter/main.c
  30. +++ sendmail-8.15.2/libmilter/main.c
  31. @@ -16,6 +16,12 @@ SM_RCSID("@(#)$Id: main.c,v 8.85 2013-11
  32. #include <fcntl.h>
  33. #include <sys/stat.h>
  34. +int thread_create(pthread_t *ptid, void *(*wr) (void *), void *arg) {
  35. + pthread_attr_t attr;
  36. + pthread_attr_init(&attr);
  37. + pthread_attr_setstacksize(&attr,2*1024*1024);
  38. + return pthread_create(ptid, &attr, wr, arg);
  39. +}
  40. static smfiDesc_ptr smfi = NULL;