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 681913 - gst_init_check cause memory leak
gst_init_check cause memory leak
Status: RESOLVED NOTABUG
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
0.10.36
Other Linux
: Normal normal
: NONE
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-08-15 13:53 UTC by Dror Asaf
Modified: 2012-08-15 14:33 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Dror Asaf 2012-08-15 13:53:55 UTC
Steps to Reproduce:
when using the hello world application with the minor change:

 gst_init(&argc, &argv) -> gst_init_check(&argc, &argv, &err)

I recieve in valgrind the following error:
==19907== 8,192 bytes in 1 blocks are definitely lost in loss record 4,381 of 4,501
==19907==    at 0x4028308: malloc (vg_replace_malloc.c:263)
==19907==    by 0x43C73AA: ??? (in /lib/i386-linux-gnu/libglib-2.0.so.0.3200.3)
==19907==    by 0x43C7722: g_malloc (in /lib/i386-linux-gnu/libglib-2.0.so.0.3200.3)
==19907==    by 0x43C79CA: g_malloc_n (in /lib/i386-linux-gnu/libglib-2.0.so.0.3200.3)
==19907==    by 0x43A5D4F: g_quark_from_static_string (in /lib/i386-linux-gnu/libglib-2.0.so.0.3200.3)
==19907==    by 0x41FE7A3: g_type_init_with_debug_flags (in /usr/lib/i386-linux-gnu/libgobject-2.0.so.0.3200.3)
==19907==    by 0x41FE97A: g_type_init (in /usr/lib/i386-linux-gnu/libgobject-2.0.so.0.3200.3)
==19907==    by 0x40FC810: gst_init_check (in /usr/lib/i386-linux-gnu/libgstreamer-0.10.so.0.30.0)
==19907==    by 0x448CE45: (below main) (libc-start.c:228)

I checked the issue only on Debian Linux 2.6.39-4, gstreamer-0.10.36
Comment 1 Tim-Philipp Müller 2012-08-15 14:02:13 UTC
Please

  sudo apt-get install libc6-dbg libglib2.0-0-dbg libgstreamer0.10-0-dbg

to get more useful output from valgrind.

However, I suspect it's not actually a leak, but a global one-time allocation of the type system.
Comment 2 Dror Asaf 2012-08-15 14:22:36 UTC
After installation, this is the output from valgrind:

8,192 bytes in 1 blocks are definitely lost in loss record 3,072 of 3,162
==24518==    at 0x4028308: malloc (vg_replace_malloc.c:263)
==24518==    by 0x409E3AA: standard_malloc (gmem.c:85)
==24518==    by 0x409E722: g_malloc (gmem.c:159)
==24518==    by 0x409E9CA: g_malloc_n (gmem.c:361)
==24518==    by 0x407CD4F: g_quark_from_static_string (gdataset.c:1281)
==24518==    by 0x44237A3: g_type_init_with_debug_flags (gtype.c:4305)
==24518==    by 0x442397A: g_type_init (gtype.c:4388)
==24518==    by 0x4321810: gst_init_check (in /usr/lib/i386-linux-gnu/libgstreamer-0.10.so.0.30.0)
==24518==    by 0x445DE45: (below main) (libc-start.c:228)

It is a one-time allocation since the call to gst_init_check is done only once.
Comment 3 Tim-Philipp Müller 2012-08-15 14:33:16 UTC
This appears to be an intentional leak inside GLib.


/* HOLDS: g_quark_global_lock */
static inline GQuark
g_quark_new (gchar *string)
{
  GQuark quark;
  gchar **g_quarks_new;
  
  if (g_quark_seq_id % G_QUARK_BLOCK_SIZE == 0)
    {
      g_quarks_new = g_new (gchar*, g_quark_seq_id + G_QUARK_BLOCK_SIZE);
      if (g_quark_seq_id != 0)
	memcpy (g_quarks_new, g_quarks, sizeof (char *) * g_quark_seq_id);
      memset (g_quarks_new + g_quark_seq_id, 0, sizeof (char *) * G_QUARK_BLOCK_SIZE);
      /* This leaks the old quarks array. Its unfortunate, but it allows
	 us to do lockless lookup of the arrays, and there shouldn't be that
	 many quarks in an app */
      g_atomic_pointer_set (&g_quarks, g_quarks_new);
    }
  if (!g_quark_ht)
    {
      g_assert (g_quark_seq_id == 0);
      g_quark_ht = g_hash_table_new (g_str_hash, g_str_equal);
      g_quarks[g_quark_seq_id] = NULL;
      g_atomic_int_inc (&g_quark_seq_id);
    }

  quark = g_quark_seq_id;
  g_atomic_pointer_set (&g_quarks[quark], string);
  g_hash_table_insert (g_quark_ht, string, GUINT_TO_POINTER (quark));
  g_atomic_int_inc (&g_quark_seq_id);

  return quark;
}


Feel free to move this to GLib and re-open it, but it does look intentional..