aboutsummaryrefslogtreecommitdiffstats
path: root/community/bareos/pthread-double-detach.patch
diff options
context:
space:
mode:
authorSimon Frankenberger <simon@fraho.eu>2019-04-05 07:43:32 +0200
committerFrancesco Colista <fcolista@alpinelinux.org>2019-04-06 17:19:56 +0000
commit37923bd0f6d4e33a3b7de6c23e708787c5d7d3bf (patch)
tree486063abc5de7b4f78c4eb438d2d63fd985e7cb0 /community/bareos/pthread-double-detach.patch
parentabf5a576b646c92413536c7c731474c6f212377f (diff)
downloadaports-37923bd0f6d4e33a3b7de6c23e708787c5d7d3bf.tar.bz2
aports-37923bd0f6d4e33a3b7de6c23e708787c5d7d3bf.tar.xz
community/bareos: Fix segfaults on startup
This PR fixes two undefined behaviours with pthreads leading to segfaults. Closes Bug #10156 https://bugs.alpinelinux.org/issues/10156
Diffstat (limited to 'community/bareos/pthread-double-detach.patch')
-rw-r--r--community/bareos/pthread-double-detach.patch43
1 files changed, 43 insertions, 0 deletions
diff --git a/community/bareos/pthread-double-detach.patch b/community/bareos/pthread-double-detach.patch
new file mode 100644
index 0000000000..e43f806bee
--- /dev/null
+++ b/community/bareos/pthread-double-detach.patch
@@ -0,0 +1,43 @@
+This patch fixes a double pthread_detach(), which is undefined behaviour
+and leads to a segfault when running with musl libc.
+Until this issue is fixed upstream this patch is needed.
+
+--- a/src/dird/ua_server.c
++++ b/src/dird/ua_server.c
+@@ -73,7 +73,15 @@
+ UAContext *ua;
+ JCR *jcr;
+
+- pthread_detach(pthread_self());
++ /* only detach if not yet detached */
++ int _detachstate;
++ pthread_attr_t _gattr;
++ pthread_getattr_np(pthread_self(), &_gattr);
++ pthread_attr_getdetachstate(&_gattr, &_detachstate);
++ pthread_attr_destroy(&_gattr);
++ if(_detachstate != PTHREAD_CREATE_DETACHED) {
++ pthread_detach(pthread_self());
++ }
+
+ jcr = new_control_jcr("-Console-", JT_CONSOLE);
+
+--- a/src/dird/job.c
++++ b/src/dird/job.c
+@@ -420,7 +420,16 @@
+ {
+ JCR *jcr = (JCR *)arg;
+
+- pthread_detach(pthread_self());
++ /* only detach if not yet detached */
++ int _detachstate;
++ pthread_attr_t _gattr;
++ pthread_getattr_np(pthread_self(), &_gattr);
++ pthread_attr_getdetachstate(&_gattr, &_detachstate);
++ pthread_attr_destroy(&_gattr);
++ if(_detachstate != PTHREAD_CREATE_DETACHED) {
++ pthread_detach(pthread_self());
++ }
++
+ Dsm_check(100);
+
+ Dmsg0(200, "=====Start Job=========\n");