aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-support/syslog-ng/files/0001-syslog-ng-fix-segment-fault-during-service-start.patch
blob: b5bfcd025a4755f2a1c82dc6e835a3cfb4a6fb77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
Subject: [PATCH] syslog-ng: fix segment fault during service start on arm64

service start failed since segment fault on arch arm64,
syslog-ng have a submodule ivykis, from ivykis V0.42,
it use pthread_atfork, but for arm64, this symbol is
not included by libpthread, so cause segment fault.

refer systemd, replace pthread_atfork with __register_atfork
to fix this problem.

I have create an issue, and this proposal to upstream.
https://github.com/buytenh/ivykis/issues/15

Upstream-Status: Pending

Signed-off-by: Changqing Li <changqing.li@windriver.com>

Update for 3.24.1.
Signed-off-by: Zheng Ruoqin <zhengrq.fnst@cn.fujitsu.com>
---
 lib/ivykis/src/pthr.h | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/lib/ivykis/src/pthr.h b/lib/ivykis/src/pthr.h
index 29e4be7..5d29096 100644
--- a/lib/ivykis/src/pthr.h
+++ b/lib/ivykis/src/pthr.h
@@ -24,6 +24,16 @@
 #include <pthread.h>
 #include <signal.h>
 
+#ifdef __GLIBC__
+/* We use glibc __register_atfork() + __dso_handle directly here, as they are not included in the glibc
+ * headers. __register_atfork() is mostly equivalent to pthread_atfork(), but doesn't require us to link against
+ * libpthread, as it is part of glibc anyway. */
+extern int __register_atfork(void (*prepare) (void), void (*parent) (void), void (*child) (void), void * __dso_handle);
+extern void* __dso_handle __attribute__ ((__weak__));
+#else
+#define __register_atfork(prepare,parent,child,dso) pthread_atfork(prepare,parent,child)
+#endif
+
 #ifdef HAVE_PRAGMA_WEAK
 #pragma weak pthread_create
 #endif
@@ -36,16 +46,7 @@ static inline int pthreads_available(void)
 
 #ifdef HAVE_PRAGMA_WEAK
 
-/*
- * On Linux, pthread_atfork() is defined in libc_nonshared.a (for
- * glibc >= 2.28) or libpthread_nonshared.a (for glibc <= 2.27), and
- * we want to avoid "#pragma weak" for that symbol because that causes
- * it to be undefined even if you link lib*_nonshared.a in explicitly.
- */
-#if !defined(HAVE_LIBC_NONSHARED) && !defined(HAVE_LIBPTHREAD_NONSHARED)
-#pragma weak pthread_atfork
-#endif
-
+#pragma weak __register_atfork
 #pragma weak pthread_create
 #pragma weak pthread_detach
 #pragma weak pthread_getspecific
@@ -73,7 +74,7 @@ static inline int
 pthr_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void))
 {
 	if (pthreads_available())
-		return pthread_atfork(prepare, parent, child);
+		return __register_atfork(prepare, parent, child, __dso_handle);
 
 	return ENOSYS;
 }
-- 
2.7.4