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 438232 - Alsasrc / alsasink's system clock threads were not been cleaned up
Alsasrc / alsasink's system clock threads were not been cleaned up
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: dont know
0.10.11
Other Linux
: Normal normal
: NONE
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2007-05-14 03:18 UTC by James CM Tsai
Modified: 2007-05-14 11:09 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description James CM Tsai 2007-05-14 03:18:31 UTC
There is a sample code which creating a simple gst pipeline which contains only one alsasrc and one alsasink element and playing it. After 2 secs, set this pipeline to null and unreference it. Sample code is as following :

#include <stdio.h>
#include <gst/gst.h>

typedef struct _loop_context
{
  GMainLoop *loop;
  guint steps;
} loop_context;

GstElement *pipeline = NULL;
#define TOTAL_STEPS 10

void
create_pipeline (void)
{
  GstElement *src = NULL, *sink = NULL;

  if (!pipeline)
  {
    g_print ("\n====== [CREATE AND RUN PIPELINE] ======\n");

    pipeline = gst_pipeline_new ("test_pipe");

    src = gst_element_factory_make ("alsasrc", "asrc");
    sink = gst_element_factory_make ("alsasink", "asink");

    gst_bin_add_many (GST_BIN(pipeline), src, sink, NULL);

    gst_element_link (src, sink);

    gst_element_set_state (pipeline, GST_STATE_PLAYING);
  }
}

void
destroy_pipeline (void)
{
  if(pipeline)
  {
    gst_element_set_state (pipeline, GST_STATE_NULL);
    gst_object_unref (GST_OBJECT (pipeline));
    pipeline = NULL;
    g_print ("====== [CLEANUP PIPELINE] ======\n");
  }
}

gboolean
one_more_step (gpointer data)
{
  loop_context *context = (loop_context *)data;

  if (context->steps >= TOTAL_STEPS)
  {
    destroy_pipeline ();
    g_main_loop_quit (context->loop);
    return FALSE;
  }
  else if ((context->steps)%2 == 0)
    create_pipeline ();
  else
    destroy_pipeline ();

  context->steps += 1;
  return TRUE;
}

int
main ()
{
  gst_init(NULL, NULL);

  loop_context *context = (loop_context *)g_malloc0 (sizeof (loop_context));
  g_return_val_if_fail(context, 0);

  context->loop = g_main_loop_new (NULL, 0);
  context->steps = 0;
  g_timeout_add (2000, one_more_step, context);
  g_main_loop_run (context->loop);
  g_main_loop_unref(context->loop);

  g_free (context);

  getchar ();

  return 1;
}

========================================

I use gdb to run this sample code. Each time pipeline been created and destroyed, there is one thread not been cleaned up. So, as sample code has 5 rounds of creating and destroying, there will be 5 more threads after all destroying are done. Following is the gdb log :

========================================

[root@localhost testing]# gdb ./pipeline-test
GNU gdb Red Hat Linux (6.5-15.fc6rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/i686/nosegneg/libthread_db.so.1".

(gdb) run
Starting program: /backup/testing/pipeline-test
[Thread debugging using libthread_db enabled]
[New Thread -1208617280 (LWP 3600)]

====== [CREATE AND RUN PIPELINE] ======
[New Thread -1210721392 (LWP 3604)]
[New Thread -1221211248 (LWP 3605)]
[New Thread -1231987824 (LWP 3606)]
[New Thread -1242477680 (LWP 3607)]
[New Thread -1252967536 (LWP 3608)]
[New Thread -1263457392 (LWP 3609)]
[Thread -1263457392 (LWP 3609) exited]
[Thread -1252967536 (LWP 3608) exited]
[Thread -1231987824 (LWP 3606) exited]
[Thread -1221211248 (LWP 3605) exited]
====== [CLEANUP PIPELINE] ======
[Thread -1242477680 (LWP 3607) exited]

====== [CREATE AND RUN PIPELINE] ======
[New Thread -1242477680 (LWP 3610)]
[New Thread -1221211248 (LWP 3611)]
[New Thread -1231987824 (LWP 3612)]
[New Thread -1252967536 (LWP 3613)]
[New Thread -1263457392 (LWP 3614)]
[New Thread -1273947248 (LWP 3615)]
[Thread -1273947248 (LWP 3615) exited]
[Thread -1263457392 (LWP 3614) exited]
[Thread -1231987824 (LWP 3612) exited]
[Thread -1221211248 (LWP 3611) exited]
====== [CLEANUP PIPELINE] ======
[Thread -1252967536 (LWP 3613) exited]

====== [CREATE AND RUN PIPELINE] ======
[New Thread -1252967536 (LWP 3616)]
[New Thread -1221211248 (LWP 3617)]
[New Thread -1231987824 (LWP 3618)]
[New Thread -1263457392 (LWP 3619)]
[New Thread -1273947248 (LWP 3620)]
[New Thread -1284437104 (LWP 3621)]
[Thread -1284437104 (LWP 3621) exited]
[Thread -1273947248 (LWP 3620) exited]
[Thread -1231987824 (LWP 3618) exited]
[Thread -1221211248 (LWP 3617) exited]
====== [CLEANUP PIPELINE] ======
[Thread -1263457392 (LWP 3619) exited]

====== [CREATE AND RUN PIPELINE] ======
[New Thread -1263457392 (LWP 3627)]
[New Thread -1221211248 (LWP 3628)]
[New Thread -1231987824 (LWP 3629)]
[New Thread -1273947248 (LWP 3630)]
[New Thread -1284437104 (LWP 3631)]
[New Thread -1294926960 (LWP 3632)]
[Thread -1294926960 (LWP 3632) exited]
[Thread -1284437104 (LWP 3631) exited]
[Thread -1231987824 (LWP 3629) exited]
[Thread -1221211248 (LWP 3628) exited]
====== [CLEANUP PIPELINE] ======
[Thread -1273947248 (LWP 3630) exited]

====== [CREATE AND RUN PIPELINE] ======
[New Thread -1273947248 (LWP 3695)]
[New Thread -1221211248 (LWP 3696)]
[New Thread -1231987824 (LWP 3697)]
[New Thread -1284437104 (LWP 3698)]
[New Thread -1294926960 (LWP 3699)]
[New Thread -1305416816 (LWP 3700)]
[Thread -1305416816 (LWP 3700) exited]
[Thread -1294926960 (LWP 3699) exited]
[Thread -1231987824 (LWP 3697) exited]
[Thread -1221211248 (LWP 3696) exited]
====== [CLEANUP PIPELINE] ======
[Thread -1284437104 (LWP 3698) exited]

Program received signal SIGINT, Interrupt.

Thread NaN (LWP 3600)

  • #0 __kernel_vsyscall
  • #1 pthread_cond_wait
    from /lib/i686/nosegneg/libpthread.so.0
  • #2 gst_system_clock_async_thread
    at gstsystemclock.c line 258
  • #3 g_thread_create_full
    from /lib/libglib-2.0.so.0
  • #4 start_thread
    from /lib/i686/nosegneg/libpthread.so.0
  • #5 clone
    from /lib/i686/nosegneg/libc.so.6
  • #0 __kernel_vsyscall
  • #1 pthread_cond_wait
    from /lib/i686/nosegneg/libpthread.so.0
  • #2 gst_system_clock_async_thread
    at gstsystemclock.c line 258
  • #3 g_thread_create_full
    from /lib/libglib-2.0.so.0
  • #4 start_thread
    from /lib/i686/nosegneg/libpthread.so.0
  • #5 clone
    from /lib/i686/nosegneg/libc.so.6

Comment 1 Wim Taymans 2007-05-14 10:13:31 UTC
This problem seems to be fixed in CVS but I cannot find which patch could have fixed this.
Comment 2 Tim-Philipp Müller 2007-05-14 10:32:30 UTC
The patch from bug #414986 maybe?
Comment 3 Wim Taymans 2007-05-14 11:09:58 UTC
Nope, I undid that patch to always start the async clock, just to be sure.