Skip to contentSkip to conversation

package/shairport-sync: Add musl patches

PATCH New Jörg Krause 2 participants 3 messages May 28, 2015 – May 29, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/shairport-sync: Add musl patches

Add patches to fix the following issues:
- shairport-sync crashes on musl libc because of a stack overflow
- warning about incorrect header includes for poll.h and signal.h

Both patches PR'ed upstream:
https://github.com/mikebrady/shairport-sync/pull/78

---
 .../0001-Fix-segfault-with-musl-libc.patch         | 63 ++++++++++++++++++++++
 ...x-redirection-of-incorrect-system-headers.patch | 56 +++++++++++++++++++
 2 files changed, 119 insertions(+)
 create mode 100644 package/shairport-sync/0001-Fix-segfault-with-musl-libc.patch
 create mode 100644 package/shairport-sync/0002-Fix-redirection-of-incorrect-system-headers.patch
package/shairport-sync/0001-Fix-segfault-with-musl-libc.patch new file +63 -0
new file mode 100644
index 0000000..7307729
@@ -0,0 +1,63 @@
+From e12d7ad23ee3c40b61c31543737dd1b929e08a53 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?J=C3=B6rg=20Krause?= <[email protected]>
+Date: Thu, 28 May 2015 09:10:59 +0200
+Subject: [PATCH 1/1] Fix segfault with musl libc
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+shairport-sync crashes on musl libc when accessing the `statistics` array in
+`player_thread_func()`. This array is quite large (60128 bytes) and the data
+for this thread exceed the the default stack size on musl libc of 80k [1].
+
+Safe and portable programs should not depend upon the default stack limit, but
+instead, explicitly allocate enough stack for each thread by using the
+pthread_attr_setstacksize routine [2].
+
+So, lets set the stack size for the `player_thread` to 128k. A follow-up patch
+may set the stack sizes for the other threads, too. The difficulty here is to
+decide how much memory to allocate for the stack.
+
+[1]
+http://wiki.musl-libc.org/wiki/Functional_differences_from_glibc#Thread_stack_size
+
+[2]
+https://computing.llnl.gov/tutorials/pthreads/#Stack
+
+Signed-off-by: J?rg Krause <[email protected]>
+---
+ player.c | 11 ++++++++++-
+ 1 file changed, 10 insertions(+), 1 deletion(-)
+
+diff --git a/player.c b/player.c
+index fcca348..561c3f2 100644
+--- a/player.c
++++ b/player.c
+@@ -42,6 +42,7 @@
+ #include <fcntl.h>
+ #include <stdlib.h>
+ #include <errno.h>
++#include <limits.h>
+ 
+ #include "config.h"
+ 
+@@ -1104,7 +1105,15 @@ int player_play(stream_cfg *stream) {
+   if (rc)
+     debug(1,"Error initialising condition variable.");
+   config.output->start(sampling_rate);
+-  pthread_create(&player_thread, NULL, player_thread_func, NULL);
++
++  size_t size = (PTHREAD_STACK_MIN + 128 * 1024);
++  pthread_attr_t tattr;
++  pthread_attr_init(&tattr);
++  rc = pthread_attr_setstacksize(&tattr, size);
++  if (rc)
++    debug(1, "Error setting stack size for player_thread: %s", strerror(errno));
++  pthread_create(&player_thread, &tattr, player_thread_func, NULL);
++  pthread_attr_destroy(&tattr);
+ 
+   return 0;
+ }
+-- 
+2.4.2
+
package/shairport-sync/0002-Fix-redirection-of-incorrect-system-headers.patch new file +56 -0

56 lines not on this page · raw message

Signature · 1 line
2.4.2
#1 lore raw

PATCH 1/1 package/shairport-sync: Add musl patches

Quoted 8 lines · J?rg Krause

Add patches to fix the following issues:
- shairport-sync crashes on musl libc because of a stack overflow
- warning about incorrect header includes for poll.h and signal.h

Both patches PR'ed upstream:
https://github.com/mikebrady/shairport-sync/pull/78

Patches have been accepted upstream now. Probably good to include in 2015.05.

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle      arnout dot vandecappelle at essensium dot com
Senior Embedded Software Architect . . . . . . +32-478-010353 (mobile)
Essensium, Mind division . . . . . . . . . . . . . . http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium . . . . . BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#2 lore raw

PATCH 1/1 package/shairport-sync: Add musl patches

Quoted 8 lines · Arnout Vandecappelle
Quoted 7 lines · J?rg Krause

Add patches to fix the following issues:
- shairport-sync crashes on musl libc because of a stack overflow
- warning about incorrect header includes for poll.h and signal.h

Both patches PR'ed upstream:
https://github.com/mikebrady/shairport-sync/pull/78

Quoted 7 lines
Quoted 1 line

Patches have been accepted upstream now. Probably good to include in
2015.05.

Thanks for the review!

If we handle runtime errors like build errors I vote for including to 2015.05, too. However, its only relevant for building with musl with is still marked as experimental.

Since both patches are accepted upstream and a new version is released we could also just bump the version to 2.2.4.

Best regards
J?rg Krause