From: Klemens Nanni Date: Wed, 31 Jan 2024 04:01:55 +0000 (+0100) Subject: Fix crash on double pthread_cancel(3) on exit X-Git-Tag: 4.3.4-dev~45^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1800%2Fhead;p=thirdparty%2Fshairport-sync.git Fix crash on double pthread_cancel(3) on exit On OpenBSD 7.4-current, failure to listen on the RTSP socket(s) results the `rtsp_listener_thread` being pthread_cancel(3)'ed twice, once through `rtsp_listen_loop()` and again via atexit(3) handler `exit_rtsp_listener()`: ``` $ nc -4l 5000 & $ nc -6l 5000 & $ shairport-sync -c/dev/null warning: could not establish a service on port 5000 -- program terminating. Is another instance of Shairport Sync running on this device? Segmentation fault (core dumped) ``` ``` Program terminated with signal SIGSEGV, Segmentation fault. 433 if (tib->tib_canceled == 0 && tid != 0 && [Current thread is 1 (process 290061)] ``` `die()` -> `exit(EXIT_FAILURE)` normally in this case, thus forgoing the first cancel and relying on the atexit handler alone. With Mike Brady. --- diff --git a/rtsp.c b/rtsp.c index ee8f2971..3d6c5f48 100644 --- a/rtsp.c +++ b/rtsp.c @@ -5694,7 +5694,7 @@ void *rtsp_listen_loop(__attribute((unused)) void *arg) { } while (1); pthread_cleanup_pop(1); // should never happen } else { - warn("could not establish a service on port %d -- program terminating. Is another instance of " + die("could not establish a service on port %d -- program terminating. Is another instance of " "Shairport Sync running on this device?", config.port); }