After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 644510 - pulsesink: deadlock when create/connect fails
pulsesink: deadlock when create/connect fails
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other Linux
: Normal normal
: 0.10.29
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2011-03-11 15:48 UTC by Philip Jägenstedt
Modified: 2011-03-11 19:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
candidate fix (2.04 KB, patch)
2011-03-11 17:02 UTC, Philip Jägenstedt
committed Details | Review
pulsesink: Fix deadlock if connecting to PA fails (958 bytes, patch)
2011-03-11 17:49 UTC, Arun Raghavan
committed Details | Review

Description Philip Jägenstedt 2011-03-11 15:48:36 UTC
My fix for https://bugzilla.gnome.org/show_bug.cgi?id=643087 introduced another deadlock instead.

If gst_pulseringbuffer_open_device reaches the goto create_failed or connect_failed between the g_mutex_lock and g_mutex_unlock, pa_shared_resource_mutex is not released.
Comment 1 Philip Jägenstedt 2011-03-11 16:24:01 UTC
What's more, this is worse than the original deadlock, because no race condition is involved, it can happen with just one pulsesink instance.
Comment 2 Philip Jägenstedt 2011-03-11 17:02:05 UTC
Created attachment 183165 [details] [review]
candidate fix

I'm not thrilled about need_unlock flags like this, but this patch is what I could cook up this afternoon.
Comment 3 Arun Raghavan 2011-03-11 17:49:36 UTC
The following fix has been pushed:
387f533 pulsesink: Fix deadlock if connecting to PA fails

Thanks, I've pushed a simpler version of your fix.
Comment 4 Arun Raghavan 2011-03-11 17:49:40 UTC
Created attachment 183171 [details] [review]
pulsesink: Fix deadlock if connecting to PA fails

Commit dd4ec22e introduced a deadlock in the failure path while trying
to connect to PulseAudio. This makes sure we drop the lock on the
resource mutex to avoid this.
Comment 5 Philip Jägenstedt 2011-03-11 18:57:20 UTC
Arun, your fix will cause g_mutex_unlock to be called twice when the function fails in the third goto. It's possible that another thread has taken the lock before we unlock it the second time. I'm not sure what the consequence would be, but I assume it's bad.
Comment 6 Arun Raghavan 2011-03-11 19:22:24 UTC
Erf, you're right. Reverted my fix and applied yours. Thanks!