Gstreamer & GLib memory management/profiling
Olivier Crête
olivier.crete at collabora.com
Fri Oct 31 08:55:08 PDT 2014
Hi,
If you attach GDB, you'll see that this is actually a GLib bug. The
g_signal_nodes table is allocated from the ctor, so before your main is
called. Then when it tries to re-alloc that with the profiler, it fail.
The g_mem_set_vtable() is actually incompatible with GObject itself...
Olivier
On 31/10/14 11:42 AM, Sergei Vorobyov wrote:
> I "forgot" the line
>
> extern GMemVTable *glib_mem_profiler_table;
>
> before int main ....
>
> (by a nasty habit of C-x C-s, which saves in emacs but kills the line
> and saves in Netbeans)
>
> But it *does not change anything*, since it is already defined somewhere
> in GLib headers.
>
>
>
> On Fri, Oct 31, 2014 at 4:34 PM, Sergei Vorobyov
> <sergei.vorobyov at facilitylabs.com
> <mailto:sergei.vorobyov at facilitylabs.com>> wrote:
>
> > I don't see why anything in GStreamer should be "incompatible" with that
> > GLib API.
>
> Neither do I. However, try a *FULL* program below:
>
> // Compile with:
> // gcc -std=c11 -Wall -pthread test.c -o test `pkg-config --cflags
> --libs glib-2.0 gstreamer-1.0 gstreamer-pbutils-1.0 gstreamer-video-1.0`
> // Run and enjoy
>
> #include <stdio.h>
> #include <stdlib.h>
>
> #include <string.h>
> #include <unistd.h>
> #include <error.h>
> #include <errno.h>
> #include <math.h>
>
> #include <glib.h>
> #include <glib/gstdio.h>
> #include <glib/gprintf.h>
>
> #include <gst/gst.h>
> #include <gst/pbutils/pbutils.h>
> #include <gst/video/videooverlay.h>
>
> int main(int argc, char** argv) {
> GError *e;
> g_mem_set_vtable (glib_mem_profiler_table);
> if (g_mem_is_system_malloc ())
> g_print ("system malloc is used\n");
> else
> g_print ("NOT system malloc is used\n");
> g_print ("********************* point 1\n");
> if (!gst_init_check (&argc, &argv, &e))
> g_print ("failed gst_init_check: %s\n", e->message);
> g_print ("********************* point 2\n");
> g_mem_profile ();
> return (EXIT_SUCCESS);
> }
>
> It produces, as expected:
>
> fl at nuc5:~/NetBeansProjects/test$ ./test
> NOT system malloc is used
> ********************* point 1
>
> (test:3987): GLib-WARNING **: free(0x1a84fd0): memory has been freed
> 12297829382473034410 times already
> *** Error in `./test': realloc(): invalid pointer:
> 0x0000000001a87e80 ***
> Aborted (core dumped)
>
>
> On Fri, Oct 31, 2014 at 2:20 PM, Tim Müller <tim at centricular.com
> <mailto:tim at centricular.com>> wrote:
>
> On Fri, 2014-10-31 at 13:46 +0100, Sergei Vorobyov wrote:
>
> Hi,
>
> > GLib's memory profiling seems incompatible with GStreamer. The
> > snippet:
>
> I don't see why anything in GStreamer should be "incompatible"
> with that
> GLib API.
>
> > extern GMemVTable *glib_mem_profiler_table;
> >
> >
> > gint main (gint argn, gchar** args) {
> > GError *e;
> > g_mem_set_vtable (glib_mem_profiler_table);
> > if (g_mem_is_system_malloc ())
> > g_print ("system malloc is used\n");
> > else
> > g_print ("NOT system malloc is used\n");
> > g_print ("********************* point 1\n");
> > if (!gst_init_check (&argn, &args, &e)) {
> > g_print ("failed gst_init_check: %s\n", e->message);
> > }
> > g_print ("********************* point 2\n");
> >
> > g_mem_profile ();
> >
> >
> > ...
> >
> >
> > crashes at gst_init producing:
> >
> >
> > fl at nuc5:~/bin$ ./mp-v01.020
> > NOT system malloc is used
> > ********************* point 1
> >
> >
> > (mp-v01.020:15561): GLib-WARNING **: free(0x1b32fd0): memory has been
> > freed 12297829382473034410 times already
> > *** Error in `./mp-v01.020': realloc(): invalid pointer:
> > 0x0000000001b35e80 ***
> > Aborted (core dumped)
>
> I would guess this is just a bug somewhere (mixing glib and non-glib
> alloc/realloc/free API somewhere). Do you have a full stack
> trace from
> gdb?
>
> Cheers
> -Tim
>
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> <mailto:gstreamer-devel at lists.freedesktop.org>
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
>
>
>
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
--
Olivier Crête
olivier.crete at collabora.com
More information about the gstreamer-devel
mailing list