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 783675 - queue2: Deadlock in Queue2 when music streaming plays long time.
queue2: Deadlock in Queue2 when music streaming plays long time.
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other All
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-06-12 08:10 UTC by Suhwang Kim
Modified: 2018-11-03 12:41 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
add the mutex to prevent access at the same time. (1.41 KB, patch)
2017-06-12 08:17 UTC, Suhwang Kim
reviewed Details | Review
This is debug log. (838.39 KB, application/gzip)
2017-06-13 00:22 UTC, Suhwang Kim
  Details

Description Suhwang Kim 2017-06-12 08:10:55 UTC
A deadlock occurred while accessing one variable in two threads.
This is sometimes issue.

One thread sets the "downstream_may_block" value.
Compares this value with another thread and executes g_cond_wait().
Deadlock occurs at this point.
Comment 1 Suhwang Kim 2017-06-12 08:17:42 UTC
Created attachment 353596 [details] [review]
add the mutex to prevent access at the same time.
Comment 2 Sebastian Dröge (slomo) 2017-06-12 08:58:55 UTC
Review of attachment 353596 [details] [review]:

::: plugins/elements/gstqueue2.c
@@ +2967,2 @@
     g_atomic_int_set (&queue->downstream_may_block, 0);
+    GST_QUEUE2_MUTEX_UNLOCK (queue);

This is atomically set, so no mutex is needed as long as the other usage of that variable is correctly done with atomic operations too. Is it not?
Comment 3 Suhwang Kim 2017-06-12 12:18:25 UTC
I tested it according to your comment, but it still takes a deadlock.
I know there is a process that supports atomic, but if it does not support our system seems to need a lock, what do you think?
Do you know how to know a process that supports atomic?
Comment 4 Nicolas Dufresne (ndufresne) 2017-06-12 12:37:11 UTC
(In reply to Suhwang Kim from comment #3)
> I tested it according to your comment, but it still takes a deadlock.
> I know there is a process that supports atomic, but if it does not support
> our system seems to need a lock, what do you think?
> Do you know how to know a process that supports atomic?

All architectures on which GLib builds have support for atomic instructions. GLib won't build, and you will have to take action if it wasn't the case.
Comment 5 Suhwang Kim 2017-06-13 00:17:23 UTC
I tested as solmo's comment. (Just using unlock)
And Got the log i attached.
I inserted some logs for debugging. You can grep using the following keywords "dbg".

As you can see the log, Thread(0x44f630) request streaming data from server.
But It is going to be locking g_cond_wait at (0:00:01.210808084). A lock is held until the seek command is encountered.(0:01:50.297251427)

If you keep playing continuously, there will be a lock forever maybe.:) 
The Thread(0x44f630) doesn't request streaming data.

I think that this problem is related with value of "downstream_may_block". 

This thread(0x2f4bb0) set the downstream_may_block.
And the other thread(0x44f630) get the downstream_may_block when some query was received. So I try to prevent this value(downstream_may_block) with mutex lock and unlock.

Do you have any other idea?
Comment 6 Suhwang Kim 2017-06-13 00:22:10 UTC
Created attachment 353641 [details]
This is debug log.
Comment 7 Sebastian Dröge (slomo) 2017-06-13 06:37:49 UTC
Can you provide a way to reproduce it? And do you think any of the usage of atomic operations for downstream_may_block is not thread-safe (and does using a mutex really solve it for you)?
Comment 8 Suhwang Kim 2017-06-13 07:18:28 UTC
I just play the music long time trough the DLNA
It's not always issue. This issue occasionally occurred.
The results I have tested so far seem to use of mutex locks.
Comment 9 Suhwang Kim 2017-06-13 10:34:19 UTC
flac audio streaming can reproduce well with DLNA.
Comment 10 Suhwang Kim 2017-06-14 08:12:13 UTC
My patch is not the right way to solve this issue.
The problem was reproduced when I applied my patch.

I think some module has stopped processing the query, so what do you think?
Comment 11 Edward Hervey 2018-01-15 11:06:45 UTC
We would need to have a backtrace to analyze what the issue is.

But my guess is that's it's indeed a problem happening at a higher level.
Comment 12 Edward Hervey 2018-08-23 07:58:12 UTC
Suhwang, can you provide a stream that reproduces this or a backtrace ?
Comment 13 GStreamer system administrator 2018-11-03 12:41:41 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/241.