| Summary: | Deadlock in SDL_CloseAudioDevice with Pulse audio | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Alex Woods <alex> |
| Component: | audio | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | Keywords: | target-2.0.12 |
| Version: | 2.0.9 | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Attachments: | A working fix | ||
Created attachment 3800 [details]
A working fix
The attached patch fixes the issue by not attempting to flush the device within the capture loop if the device is being shut down.
(Sorry if you get several emails like this, we're marking a bunch of bugs.) We're hoping to ship SDL 2.0.11 on a much shorter timeframe than we have historically done releases, so I'm starting to tag bugs we hope to have closed in this release cycle. Note that this tag means we just intend to scrutinize this bug for the 2.0.11 release: we may fix it, reject it, or even push it back to a later release for now, but this helps give us both a goal and a wishlist for the next release. If this bug has been quiet for a few months and you have new information (such as, "this is definitely still broken" or "this got fixed at some point"), please feel free to retest and/or add more notes to the bug. --ryan. We're changing how we do SDL release versions; now releases will be even numbers (2.0.10, 2.0.12, etc), and as soon as we tag a release, we'll move the internal version number to an odd number (2.0.12 ships, we tag the latest in revision control as 2.0.13 immediately, which will become 2.0.14 on release, etc). As such, I'm moving the bugs tagged with target-2.0.11 to target 2.0.12. Sorry if you get a lot of email from this change! Thanks, --ryan. We're changing how we do SDL release versions; now releases will be even numbers (2.0.10, 2.0.12, etc), and as soon as we tag a release, we'll move the internal version number to an odd number (2.0.12 ships, we tag the latest in revision control as 2.0.13 immediately, which will become 2.0.14 on release, etc). As such, I'm moving the bugs tagged with target-2.0.11 to target 2.0.12. Sorry if you get a lot of email from this change! Thanks, --ryan. (In reply to Alex Woods from comment #1) > Created attachment 3800 [details] > A working fix > > The attached patch fixes the issue by not attempting to flush the device > within the capture loop if the device is being shut down. This patch avoids calling FlushCapture in the upper level loop when the device is in shutdown when it hits the "paused" test, but since it no longer takes the paused branch in this case, it will make Pulse read from the device again, which is probably not what we want. Instead, I made Pulse's FlushCapture implementation not go into an infinite loop on device error or shutdown, in https://hg.libsdl.org/SDL/rev/fb600198ec12 ... I believe this will also solve the problem, but more directly. Please reopen this bug if I'm wrong, though! --ryan. |
It's possible for SDL_CloseAudioDevice to deadlock on pulse audio capture devices with unlucky timing. The closing thread is stuck trying to join the thread, whilst the SDL capture thread is polling in its flush function. e.g.: Closing thread: #0 0x00007ffff7b5a495 in __GI___pthread_timedjoin_ex ( threadid=140736808871680, thread_return=thread_return@entry=0x0, abstime=abstime@entry=0x0, block=block@entry=true) at pthread_join_common.c:89 #1 0x00007ffff7b5a26c in __pthread_join (threadid=<optimized out>, thread_return=thread_return@entry=0x0) at pthread_join.c:24 #2 0x00007ffff7c5247b in SDL_SYS_WaitThread (thread=thread@entry=0x9c5ff0) at ./src/thread/pthread/SDL_systhread.c:315 #3 0x00007ffff7bdf1f6 in SDL_WaitThread_REAL (thread=0x9c5ff0, status=status@entry=0x0) at ./src/thread/SDL_thread.c:471 #4 0x00007ffff7b95b23 in close_audio_device (device=0xa208d0) at ./src/audio/SDL_audio.c:1117 SDLAudioC2 thread: #0 0x00007ffff775b916 in __GI_ppoll (fds=0xa1b330, nfds=3, timeout=<optimized out>, sigmask=sigmask@entry=0x0) at ../sysdeps/unix/sysv/linux/ppoll.c:39 #1 0x00007ffff75369a1 in ppoll (__ss=0x0, __timeout=<optimized out>, __nfds=<optimized out>, __fds=<optimized out>) at /usr/include/x86_64-linux-gnu/bits/poll2.h:77 #2 pa_mainloop_poll (m=m@entry=0xa205d0) at pulse/mainloop.c:852 #3 0x00007ffff7536f6e in pa_mainloop_iterate (m=0xa205d0, block=<optimized out>, retval=0x0) at pulse/mainloop.c:926 #4 0x00007ffff7c38a98 in PULSEAUDIO_FlushCapture (this=0xa208d0) at ./src/audio/pulseaudio/SDL_pulseaudio.c:429 #5 0x00007ffff7b96c9f in SDL_CaptureAudio (devicep=devicep@entry=0xa208d0) at ./src/audio/SDL_audio.c:882 #6 0x00007ffff7bdee8c in SDL_RunThread (data=0x9bb860) at ./src/thread/SDL_thread.c:283 #7 0x00007ffff7c52119 in RunThread (data=<optimized out>) at ./src/thread/pthread/SDL_systhread.c:78