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 768179 - Hang while changing to pause mode in id3demux
Hang while changing to pause mode in id3demux
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
1.4.1
Other Linux
: Normal major
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-06-29 12:34 UTC by Jyoti tripathi
Modified: 2018-11-03 12:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
ID3 hang on changing state to pause (680.18 KB, application/x-bzip)
2016-06-29 12:34 UTC, Jyoti tripathi
Details
Id3 hang issue (22.44 KB, text/x-csrc)
2016-06-30 13:26 UTC, Jyoti tripathi
Details

Description Jyoti tripathi 2016-06-29 12:34:57 UTC
Created attachment 330570 [details]
ID3 hang on changing state to pause

Hang is seen while changing state to pause on multiple playbacks of few id3v2 tag files.
On analysing this issue I found that while changing typefind from push to pull mode, it performs a gst_pad_pause_task where it is trying to take STREAM_LOCK and hangs there.
Logs attached.
This issue cannot be seen if id3demux is in push mode.
Comment 1 Sebastian Dröge (slomo) 2016-06-29 16:03:56 UTC
Can you try with 1.8.2, and also get a backtrace of all threads when it hangs? Alternatively please provide a small, runnable testcase that reproduces your problem.

What is the pipeline that is used, which non-standard (e.g. hardware specific) elements are used and do you still have the problem without them?
Comment 2 Jyoti tripathi 2016-06-30 07:16:24 UTC
Below is the pipeline that I am using :
gst-launch-1.0 filesrc location=/home/jyoti/Documents/mp3/8kbps_32khz_2ch.mp3 ! typefind ! id3demux ! mpegaudioparse ! avdec_mp3 ! audioconvert ! capsfilter caps="audio/x-raw,channels=2" ! volume ! audioresample ! capsfilter caps="audio/x-raw,rate=48000" ! alsasink

Issue is seen only on recursively creating and destroying the pipeline.Below are the steps that we take to create the pipeline:
1.Create elements source, typefind, faksink, put them to bin and set pipeline state to PAUSE.
2.In callback function of typefind, depending on the type we create the demuxers.
3 Based on the caps notification from the demuxer, we create rest of the elements and sync there state and set pipeline to play.
4. Once pipeline is set to play,to destroy we get the state of pipeline if not NULL, we set state to NULL and unref the pipeline.

The above steps are repeated for about 200-500 times and we get no caps notification from id3demux because of the hang mentioned.

Will update on the other queries and sample application as soon as possible.
Comment 3 Jyoti tripathi 2016-06-30 13:26:32 UTC
Created attachment 330657 [details]
Id3 hang issue

Attached the test app file to verify this issue.
Usage: ./a.out <filelocation>
Also I tried on PC with the same test app but can not reproduce this issue though I could reproduce this on freescale board(gstreamer version 1.4.1)
Comment 4 Jyoti tripathi 2016-07-15 13:00:55 UTC
Is there any update on this bug? It looks like typefind src pad mode changing from push to pull is hanging. Not able to complete activation of pull mode.

Can you please check and update the same?

We are not able to change status. Please update status.
If still more information needed let us know.
Comment 5 Sebastian Dröge (slomo) 2016-07-21 14:42:22 UTC
Can you check on the Freescale board if you can reproduce it with 1.8.2 or GIT master? There were some related changes to the typefind element during 1.8.

If this is not reproducible by anybody, it's going to be a bit tricky to fix.
Comment 6 Vincent Penquerc'h 2016-08-02 15:35:37 UTC
I got it to happen once:

Thread 2 (Thread 0x7f8bcd21d700 (LWP 6448))

  • #0 __lll_lock_wait
    at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S line 135
  • #1 __GI___pthread_mutex_lock
    at ../nptl/pthread_mutex_lock.c line 116
  • #2 gst_element_set_state_func
    at gstelement.c line 2576
  • #3 gst_element_sync_state_with_parent
    at gstelement.c line 2079
  • #4 type_found
  • #5 ffi_call_unix64
    at ../src/x86/unix64.S line 76
  • #6 ffi_call
    at ../src/x86/ffi64.c line 525
  • #11 <emit signal ??? on instance 0x1291240 [GstTypeFindElement]>
    at gsignal.c line 3439
  • #12 gst_type_find_element_emit_have_type
    at gsttypefindelement.c line 237
  • #13 gst_type_find_element_loop
    at gsttypefindelement.c line 1159
  • #14 gst_task_func
    at gsttask.c line 334
  • #15 g_thread_pool_thread_proxy
    at gthreadpool.c line 307
  • #16 g_thread_proxy
    at gthread.c line 778
  • #17 start_thread
    at pthread_create.c line 334
  • #18 clone
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S line 109

Comment 7 Vincent Penquerc'h 2016-08-03 07:54:28 UTC
Better stack trace (I was using a non current branch of master for the one above):

Thread 2 (Thread 0x7f8bcd21d700 (LWP 6448))

  • #0 __lll_lock_wait
    at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S line 135
  • #1 __GI___pthread_mutex_lock
    at ../nptl/pthread_mutex_lock.c line 116
  • #2 gst_element_set_state_func
    at gstelement.c line 2576
  • #3 gst_element_sync_state_with_parent
    at gstelement.c line 2079
  • #4 type_found
  • #5 ffi_call_unix64
    at ../src/x86/unix64.S line 76
  • #6 ffi_call
    at ../src/x86/ffi64.c line 525
  • #11 <emit signal ??? on instance 0x1291240 [GstTypeFindElement]>
    at gsignal.c line 3439
  • #12 gst_type_find_element_emit_have_type
    at gsttypefindelement.c line 237
  • #13 gst_type_find_element_loop
    at gsttypefindelement.c line 1159
  • #14 gst_task_func
    at gsttask.c line 334
  • #15 g_thread_pool_thread_proxy
    at gthreadpool.c line 307
  • #16 g_thread_proxy
    at gthread.c line 778
  • #17 start_thread
    at pthread_create.c line 334
  • #18 clone
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S line 109

Comment 8 Vincent Penquerc'h 2016-08-03 14:16:12 UTC
I wonder if the gst_element_sync_state_with_parent ought not be done in a idle pad block. As in, I'm not sure whether this is a real bug in gst, or just a "don't do that, then".

slomo ? :)
Comment 9 Sebastian Dröge (slomo) 2016-08-03 14:22:08 UTC
You should never do state changes from the corresponding streaming thread, which an IDLE probe might be. You can only change states of downstream elements at that point.
Comment 10 Vincent Penquerc'h 2016-08-03 14:25:01 UTC
So that leaves an g_idle routine I guess. The type found callback is squarely in the streaming thread anyway.
So I guess this can be closed, unless the reported thinks there's something else going on.
Comment 11 Tim-Philipp Müller 2016-08-04 10:09:53 UTC
Can't use g_idle_*() since we can't assume that someone is running a glib main loop / iterating a main context (unless your element is doing it for its own stuff). Helper thread/task should work.
Comment 12 Jyoti tripathi 2016-08-04 11:50:15 UTC
As per my understanding sync_state_with_parent is causing the issue. Can gst_element_set_state be used in its place to avoid this issue?As I want my elements to be in paused state(state of BIN)after adding to pipeline.
Comment 13 Sebastian Dröge (slomo) 2016-08-04 11:52:25 UTC
It has the same problems, the problem is calling gst_element_set_state() from a streaming thread on an element that is currently inside this very streaming thread.
Comment 14 Jyoti tripathi 2016-08-04 12:06:57 UTC
So what can be an alternative to this? Changing elements state from non streaming thread? and all the calls to set_state should be called from separate thread. Also as I can see in playbin code elements state is changed within the same thread after locking the element and then unlocking it but I dont see this issue using playbin.
Comment 15 Tim-Philipp Müller 2016-11-11 17:12:54 UTC
Sebastian, my reading of the stack trace in comment #7 is that we're in the typefind type-found callback (streaming thread), and there we have added a new id3demux element downstream which we're setting to the state of the pipeline via _sync_state().

This should surely be alright?

We must set the state in the callback here otherwise it will be racy and typefind might push a buffer on a not-yet-active element.

Maybe the problem is _sync_state() and it should just be _set_state() ?

I also wouldn't be surprised if there's a bug in typefind or tagdemux, both have fairly complicated logic to switch pad modes and such on the fly IIRC.
Comment 16 GStreamer system administrator 2018-11-03 12:35:21 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/178.