]> git.ipfire.org Git - thirdparty/shairport-sync.git/commit
Fix crash on double pthread_cancel(3) on exit 1800/head
authorKlemens Nanni <kn@openbsd.org>
Wed, 31 Jan 2024 04:01:55 +0000 (05:01 +0100)
committerKlemens Nanni <kn@openbsd.org>
Thu, 1 Feb 2024 17:35:35 +0000 (18:35 +0100)
commit783d600a100fe2be707adc3b2d74f63456f1ee4d
tree6853da38f93e59a2391371937fda8663726be34c
parent750e43bcafc44d707cef88eee6cc311ac9047395
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.
rtsp.c