-
-
Notifications
You must be signed in to change notification settings - Fork 583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix crash on double pthread_cancel(3) on exit #1800
Fix crash on double pthread_cancel(3) on exit #1800
Conversation
After this,
I refrained from this intrusive change, given that it seems to break from the overall coding style/thread model. |
Great work -- let me check this out, please.
This is a throwback to an early idea that Shairport Sync, once initialised, might do more than just listen on a single RTSP thread. For instance, it might listen on two RTSP threads, or might so something completely different as well. As it stands, it doesn't do anything, but it's probably no harm to leave it as it is for the present. Whaddyathink? |
No harm being consistent with how all the other tasks are handled in their own thread. It certainly works now, other than cosmetics I'd have no reason to touch it now. |
Thanks again for looking at this, but I would not quite agree with your analysis. The reason for the crash is that the However, I think it's important to keep the This means that the
to
causing an immediate abnormal exit. What would you think? |
What difference does it make (in this case)? RTSP
Works as well, but also aptly returns Let's do that, thanks. |
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.
79e6ee0
to
783d600
Compare
Many thanks again for this. |
Process teardown stops all threads, thus calling pthread_cancel(3) in an
atexit(3) handler immediately before main() exits seems redundant.
On OpenBSD 7.4-current, failure to listen on the RTSP socket triggers
Fix this by omitting the explicit pthread_cancel(3), at which point
exit_rtsp_listener() becomes redundant, so remove it entirely.