Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | Subject: [PATCH] syslog-ng: fix segment fault during service start on arm64 |
| 2 | |
| 3 | service start failed since segment fault on arch arm64, |
| 4 | syslog-ng have a submodule ivykis, from ivykis V0.42, |
| 5 | it use pthread_atfork, but for arm64, this symbol is |
| 6 | not included by libpthread, so cause segment fault. |
| 7 | |
| 8 | refer systemd, replace pthread_atfork with __register_atfork |
| 9 | to fix this problem. |
| 10 | |
| 11 | I have create an issue, and this proposal to upstream. |
| 12 | https://github.com/buytenh/ivykis/issues/15 |
| 13 | |
| 14 | Upstream-Status: Pending |
| 15 | |
| 16 | Signed-off-by: Changqing Li <changqing.li@windriver.com> |
Brad Bishop | 2f97392 | 2019-11-11 07:58:48 -0500 | [diff] [blame] | 17 | |
| 18 | Update for 3.24.1. |
| 19 | Signed-off-by: Zheng Ruoqin <zhengrq.fnst@cn.fujitsu.com> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 20 | --- |
Brad Bishop | 2f97392 | 2019-11-11 07:58:48 -0500 | [diff] [blame] | 21 | lib/ivykis/src/pthr.h | 23 ++++++++++++----------- |
| 22 | 1 file changed, 12 insertions(+), 11 deletions(-) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 23 | |
| 24 | diff --git a/lib/ivykis/src/pthr.h b/lib/ivykis/src/pthr.h |
Brad Bishop | 2f97392 | 2019-11-11 07:58:48 -0500 | [diff] [blame] | 25 | index 29e4be7..5d29096 100644 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 26 | --- a/lib/ivykis/src/pthr.h |
| 27 | +++ b/lib/ivykis/src/pthr.h |
| 28 | @@ -24,6 +24,16 @@ |
| 29 | #include <pthread.h> |
| 30 | #include <signal.h> |
| 31 | |
| 32 | +#ifdef __GLIBC__ |
| 33 | +/* We use glibc __register_atfork() + __dso_handle directly here, as they are not included in the glibc |
| 34 | + * headers. __register_atfork() is mostly equivalent to pthread_atfork(), but doesn't require us to link against |
| 35 | + * libpthread, as it is part of glibc anyway. */ |
| 36 | +extern int __register_atfork(void (*prepare) (void), void (*parent) (void), void (*child) (void), void * __dso_handle); |
| 37 | +extern void* __dso_handle __attribute__ ((__weak__)); |
| 38 | +#else |
| 39 | +#define __register_atfork(prepare,parent,child,dso) pthread_atfork(prepare,parent,child) |
| 40 | +#endif |
| 41 | + |
| 42 | #ifdef HAVE_PRAGMA_WEAK |
| 43 | #pragma weak pthread_create |
| 44 | #endif |
| 45 | @@ -36,16 +46,7 @@ static inline int pthreads_available(void) |
| 46 | |
| 47 | #ifdef HAVE_PRAGMA_WEAK |
| 48 | |
| 49 | -/* |
Brad Bishop | 2f97392 | 2019-11-11 07:58:48 -0500 | [diff] [blame] | 50 | - * On Linux, pthread_atfork() is defined in libc_nonshared.a (for |
| 51 | - * glibc >= 2.28) or libpthread_nonshared.a (for glibc <= 2.27), and |
| 52 | - * we want to avoid "#pragma weak" for that symbol because that causes |
| 53 | - * it to be undefined even if you link lib*_nonshared.a in explicitly. |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 54 | - */ |
Brad Bishop | 2f97392 | 2019-11-11 07:58:48 -0500 | [diff] [blame] | 55 | -#if !defined(HAVE_LIBC_NONSHARED) && !defined(HAVE_LIBPTHREAD_NONSHARED) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 56 | -#pragma weak pthread_atfork |
| 57 | -#endif |
| 58 | - |
| 59 | +#pragma weak __register_atfork |
| 60 | #pragma weak pthread_create |
| 61 | #pragma weak pthread_detach |
| 62 | #pragma weak pthread_getspecific |
Brad Bishop | 2f97392 | 2019-11-11 07:58:48 -0500 | [diff] [blame] | 63 | @@ -73,7 +74,7 @@ static inline int |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 64 | pthr_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)) |
| 65 | { |
| 66 | if (pthreads_available()) |
| 67 | - return pthread_atfork(prepare, parent, child); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 68 | + return __register_atfork(prepare, parent, child, __dso_handle); |
Brad Bishop | 2f97392 | 2019-11-11 07:58:48 -0500 | [diff] [blame] | 69 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 70 | return ENOSYS; |
| 71 | } |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 72 | -- |
| 73 | 2.7.4 |
| 74 | |