GLIB warnings on Ubuntu 12.04

3,027 views
Skip to first unread message

Eran Ifrah

unread,
May 3, 2012, 3:33:17 PM5/3/12
to wx-u...@googlegroups.com
Hi All,

I upgraded my Ubuntu today to Ubuntu 12.04 in order to confirm that this bug http://trac.wxwidgets.org/ticket/13962#comment:9 is indeed fixed


After the upgrade was completed, I compiled wx-trunk / codelite and launched codelite - so far so good.

However, when I closed codelite IDE, I got bunch of these warnings:
...
LIBDBUSMENU-GLIB-WARNING **: Trying to remove a child that doesn't believe we're it's parent.
...

So, I tried to see if I can reproduce it with the minimal sample that comes with wxTrunk, so I launched the minimal sample and closed it (the warning are during process termination) and I got these messages:

...
(minimal:8605): LIBDBUSMENU-GLIB-WARNING **: Trying to remove a child that doesn't believe we're it's parent.
...


Running 'minimal' under gdb like this:

G_DEBUG=fatal_warnings gdb ./minimal

Gives this backtrace on exit:

#17 0x00007ffff70f7826 in wxWindow::~wxWindow (this=0x748b00, __in_chrg=<optimized out>) at ../src/gtk/window.cpp:2351
#18 0x00007ffff724b493 in wxMenuBarBase::~wxMenuBarBase (this=0x748b00, __in_chrg=<optimized out>) at ../src/common/menucmn.cpp:811
#19 0x00007ffff7156d1a in wxMenuBar::~wxMenuBar (this=0x748b00, __in_chrg=<optimized out>) at ../include/wx/gtk/menu.h:18
#20 0x00007ffff71f52a9 in wxDELETE<wxMenuBar> (ptr=@0x70a1a0: 0x748b00) at ../include/wx/defs.h:590
#21 0x00007ffff71f3b00 in wxFrameBase::DeleteAllBars (this=0x709e40) at ../src/common/framecmn.cpp:171
#22 0x00007ffff71496fb in wxFrame::~wxFrame (this=0x709e40, __in_chrg=<optimized out>) at ../src/gtk/frame.cpp:63
#23 0x000000000040de3f in MyFrame::~MyFrame (this=0x709e40, __in_chrg=<optimized out>) at ../../../samples/minimal/minimal.cpp:62
#24 0x00007ffff6f530e4 in wxAppConsoleBase::DeletePendingObjects (this=0x6715e0) at ../src/common/appbase.cpp:571
#25 0x00007ffff6f5292f in wxAppConsoleBase::ProcessIdle (this=0x6715e0) at ../src/common/appbase.cpp:377
#26 0x00007ffff7187aab in wxAppBase::ProcessIdle (this=0x6715e0) at ../src/common/appcmn.cpp:346
#27 0x00007ffff70b746c in wxApp::DoIdle (this=0x6715e0) at ../src/gtk/app.cpp:141
#28 0x00007ffff70b738f in wxapp_idle_callback () at ../src/gtk/app.cpp:110
#29 0x00007ffff3d1dc9a in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#30 0x00007ffff3d1e060 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#31 0x00007ffff3d1e45a in g_main_loop_run () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#32 0x00007ffff5faa2f7 in gtk_main () from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
#33 0x00007ffff70dac2e in wxGUIEventLoop::Run (this=0x74b5c0) at ../src/gtk/evtloop.cpp:60
#34 0x00007ffff6f526c7 in wxAppConsoleBase::MainLoop (this=0x6715e0) at ../src/common/appbase.cpp:314
#35 0x00007ffff6f524f5 in wxAppConsoleBase::OnRun (this=0x6715e0) at ../src/common/appbase.cpp:255
#36 0x00007ffff7187837 in wxAppBase::OnRun (this=0x6715e0) at ../src/common/appcmn.cpp:284
#37 0x00007ffff6fc1faa in wxEntry (argc=@0x7ffff7db7570: 1, argv=0x66be30) at ../src/common/init.cpp:472
#38 0x00007ffff6fc206a in wxEntry (argc=@0x7fffffffe01c: 1, argv=0x7fffffffe108) at ../src/common/init.cpp:484
#39 0x0000000000409dc5 in main (argc=1, argv=0x7fffffffe108) at ../../../samples/minimal/minimal.cpp:109

Any hint? anyone else seen this?

-- 
Eran Ifrah
Author of the cross platform, open source C++ IDE: http://www.codelite.org
YTubePlayer http://www.ytubeplayer.com

Vadim Zeitlin

unread,
May 3, 2012, 5:13:51 PM5/3/12
to wx-u...@googlegroups.com
On Thu, 3 May 2012 22:33:17 +0300 Eran Ifrah wrote:

EI> I upgraded my Ubuntu today to Ubuntu 12.04 in order to confirm that this
EI> bug http://trac.wxwidgets.org/ticket/13962#comment:9 is indeed fixed

Thanks for testing, I've closed it now.

EI> So, I tried to see if I can reproduce it with the minimal sample that comes
EI> with wxTrunk, so I launched the minimal sample and closed it (the warning
EI> are during process termination) and I got these messages:
EI>
EI> ...
EI> (minimal:8605): LIBDBUSMENU-GLIB-WARNING **: Trying to remove a child that
EI> doesn't believe we're it's parent.
EI> ...
EI>
EI> Running 'minimal' under gdb like this:
EI>
EI> G_DEBUG=fatal_warnings gdb ./minimal
EI>
EI> Gives this backtrace on exit:
EI>
EI> #17 0x00007ffff70f7826 in wxWindow::~wxWindow (this=0x748b00,
EI> __in_chrg=<optimized out>) at ../src/gtk/window.cpp:2351
EI> #18 0x00007ffff724b493 in wxMenuBarBase::~wxMenuBarBase (this=0x748b00,
EI> __in_chrg=<optimized out>) at ../src/common/menucmn.cpp:811
EI> #19 0x00007ffff7156d1a in wxMenuBar::~wxMenuBar (this=0x748b00,
EI> __in_chrg=<optimized out>) at ../include/wx/gtk/menu.h:18
EI> #20 0x00007ffff71f52a9 in wxDELETE<wxMenuBar> (ptr=@0x70a1a0: 0x748b00) at
EI> ../include/wx/defs.h:590
...
EI> Any hint? anyone else seen this?

No, sorry. Looking at the code in wxFrame::AttachMenuBar() which adds menu
bar to m_mainWidget at GTK level I don't see anything wrong, this is what a
typical GTK application would do too, I think.

Could you please check what is the parent of the widget? Also, what about
the previous 16 stack frames, is there nothing useful in them?

Thanks,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

Eran Ifrah

unread,
May 4, 2012, 3:49:55 AM5/4/12
to wx-u...@googlegroups.com
I placed a breakpoint at frame 8 and checked the member m_widget->parent
The 'parent' is set to NULL

I later tried this:

I added a write watchpoint after the menu bar creation to "((GtkWidget *)0x6be420)->parent" (where '0x6be420' is the menubar widget)
I then exited the minimal sample and I got 2 "breaks"

The first one was issued because of the watchpoint, and here is the stack trace:

0  0x00007ffff60cbf93  gtk_widget_unparent    
1  0x00007ffff5efa935  ??    
2  0x00007ffff43e8354  g_cclosure_marshal_VOID__OBJECTv    
3  0x00007ffff43e4eca  ??    
4  0x00007ffff43fd741  g_signal_emit_valist    
5  0x00007ffff43fe242  g_signal_emit    
6  0x00007ffff60ceb45  ??    
7  0x00007ffff43eb000  g_object_run_dispose    
8  0x00007ffff70f7826  wxWindow::~wxWindow  /home/eran/devl/wx-trunk/src/gtk/window.cpp  2351
9  0x00007ffff724b493  wxMenuBarBase::~wxMenuBarBase  /home/eran/devl/wx-trunk/src/common/menucmn.cpp  811
10  0x00007ffff7156d1a  wxMenuBar::~wxMenuBar  /home/eran/devl/wx-trunk/include/wx/gtk/menu.h  18
11  0x00007ffff71f52a9  wxDELETE<wxMenuBar>  /home/eran/devl/wx-trunk/include/wx/defs.h  590
12  0x00007ffff71f3b00  wxFrameBase::DeleteAllBars  /home/eran/devl/wx-trunk/src/common/framecmn.cpp  171
13  0x00007ffff71496fb  wxFrame::~wxFrame  /home/eran/devl/wx-trunk/src/gtk/frame.cpp  63
14  0x000000000040de3f  MyFrame::~MyFrame  /home/eran/devl/wx-trunk/samples/minimal/minimal.cpp  62

so at this point the 'parent' was set to NULL.

I then hit Continue, and got the second assertion failure:

0  0x00007ffff3d24f9b  g_logv    
1  0x00007ffff3d25172  g_log    
2  0x00007fffe505491f  dbusmenu_menuitem_child_delete    
3  0x00007ffff43e4ca2  g_closure_invoke    
4  0x00007ffff43f5d71  ??    
5  0x00007ffff43fe099  g_signal_emit_valist    
6  0x00007ffff43fe242  g_signal_emit    
7  0x00007ffff60ceb45  ??    
8  0x00007ffff43eb000  g_object_run_dispose    
9  0x00007ffff5fbf4c5  ??    
10  0x00007ffff5f2fdcf  ??    
11  0x00007ffff43e4ca2  g_closure_invoke    
12  0x00007ffff43f5c31  ??    
13  0x00007ffff43fe099  g_signal_emit_valist    
14  0x00007ffff43fe242  g_signal_emit    
15  0x00007ffff5fd52c0  ??    
16  0x00007ffff43eb000  g_object_run_dispose    
17  0x00007ffff70f7826  wxWindow::~wxWindow  /home/eran/devl/wx-trunk/src/gtk/window.cpp  2351
18  0x00007ffff724b493  wxMenuBarBase::~wxMenuBarBase  /home/eran/devl/wx-trunk/src/common/menucmn.cpp  811
19  0x00007ffff7156d1a  wxMenuBar::~wxMenuBar  /home/eran/devl/wx-trunk/include/wx/gtk/menu.h  18
20  0x00007ffff71f52a9  wxDELETE<wxMenuBar>  /home/eran/devl/wx-trunk/include/wx/defs.h  590
21  0x00007ffff71f3b00  wxFrameBase::DeleteAllBars  /home/eran/devl/wx-trunk/src/common/framecmn.cpp  171
22  0x00007ffff71496fb  wxFrame::~wxFrame  /home/eran/devl/wx-trunk/src/gtk/frame.cpp  63
23  0x000000000040de3f  MyFrame::~MyFrame  /home/eran/devl/wx-trunk/samples/minimal/minimal.cpp  62
24  0x00007ffff6f530e4  wxAppConsoleBase::DeletePendingObjects  /home/eran/devl/wx-trunk/src/common/appbase.cpp  571
25  0x00007ffff6f5292f  wxAppConsoleBase::ProcessIdle  /home/eran/devl/wx-trunk/src/common/appbase.cpp  377
26  0x00007ffff7187aab  wxAppBase::ProcessIdle  /home/eran/devl/wx-trunk/src/common/appcmn.cpp  346
27  0x00007ffff70b746c  wxApp::DoIdle  /home/eran/devl/wx-trunk/src/gtk/app.cpp  141
28  0x00007ffff70b738f  wxapp_idle_callback  /home/eran/devl/wx-trunk/src/gtk/app.cpp  110
29  0x00007ffff3d1dc9a  g_main_context_dispatch    
30  0x00007ffff3d1e060  ??    
31  0x00007ffff3d1e45a  g_main_loop_run    
32  0x00007ffff5faa2f7  gtk_main    
33  0x00007ffff70dac2e  wxGUIEventLoop::Run  /home/eran/devl/wx-trunk/src/gtk/evtloop.cpp  60
34  0x00007ffff6f526c7  wxAppConsoleBase::MainLoop  /home/eran/devl/wx-trunk/src/common/appbase.cpp  314
35  0x00007ffff6f524f5  wxAppConsoleBase::OnRun  /home/eran/devl/wx-trunk/src/common/appbase.cpp  255
36  0x00007ffff7187837  wxAppBase::OnRun  /home/eran/devl/wx-trunk/src/common/appcmn.cpp  284
37  0x00007ffff6fc1faa  wxEntry  /home/eran/devl/wx-trunk/src/common/init.cpp  472
38  0x00007ffff6fc206a  wxEntry  /home/eran/devl/wx-trunk/src/common/init.cpp  484
39  0x0000000000409dc5  main  /home/eran/devl/wx-trunk/samples/minimal/minimal.cpp  109

Note that even though its only a warnings, it might indicate that something is wrong somewhere
I run gdb like this:

gdb ./minimal 
run --g-fatal-warnings

HTH

 Could you please check what is the parent of the widget? Also, what about
the previous 16 stack frames, is there nothing useful in them?

 Thanks,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
              http://www.tt-solutions.com/

Vadim Zeitlin

unread,
May 4, 2012, 5:47:18 AM5/4/12
to wx-u...@googlegroups.com
On Fri, 4 May 2012 10:49:55 +0300 Eran Ifrah wrote:

EI> I placed a breakpoint at frame 8 and checked the member m_widget->parent
EI> The 'parent' is set to NULL

Sorry, what is frame 8?

Anyhow, AFAIU the parent is initially NULL, then set when the menu bar is
added to the main frame in wxFrame::AttachMenuBar() and should remain set
until the menu bar is deleted.

EI> I added a write watchpoint after the menu bar creation to "((GtkWidget
EI> *)0x6be420)->parent" (where '0x6be420' is the menubar widget)
EI> I then exited the minimal sample and I got 2 "breaks"

Both of them are inside gtk_widget_destroy() (BTW, I have it on line 2357,
not 2351, why the discrepancy?) so it's too late to do anything by then...
The bug must occur earlier, whatever it is.

EI> Note that even though its only a warnings, it might indicate that something
EI> is wrong somewhere

Yes, I do take it seriously. I just don't know what to do about it, sorry.

Eran Ifrah

unread,
May 4, 2012, 5:58:02 AM5/4/12
to wx-u...@googlegroups.com
On Fri, May 4, 2012 at 12:47 PM, Vadim Zeitlin <va...@wxwidgets.org> wrote:
On Fri, 4 May 2012 10:49:55 +0300 Eran Ifrah wrote:

EI> I placed a breakpoint at frame 8 and checked the member m_widget->parent
EI> The 'parent' is set to NULL

 Sorry, what is frame 8?

Sorry for not being cleared, I meant window.cpp:2351 as in 'frame 8' from the backtrace

8  0x00007ffff70f7826  wxWindow::~wxWindow  /home/eran/devl/wx-trunk/src/gtk/window.cpp  2351

 
 Anyhow, AFAIU the parent is initially NULL, then set when the menu bar is

added to the main frame in wxFrame::AttachMenuBar() and should remain set
until the menu bar is deleted.

Indeed, the 'parent' member of the menubar is pointing to the m_mainWidget wxFrame after AttachMenuBar this is true. The problem
is not when constructing the frame, the problem is when destroying it.

EI> I added a write watchpoint after the menu bar creation to "((GtkWidget
EI> *)0x6be420)->parent" (where '0x6be420' is the menubar widget)
EI> I then exited the minimal sample and I got 2 "breaks"

 Both of them are inside gtk_widget_destroy()
 
(BTW, I have it on line 2357,
 
Yes, I need to update my trunk (note that these warnings are also happening with wx2.8.12) 
 
not 2351, why the discrepancy?) so it's too late to do anything by then...
The bug must occur earlier, whatever it is.

EI> Note that even though its only a warnings, it might indicate that something
EI> is wrong somewhere

 Yes, I do take it seriously. I just don't know what to do about it, sorry.
VZ

Just an FYI:
I compiled GTK sample ( http://www.gtk.org/tutorial1.2/gtk_tut-13.html#ss13.2 ) for Menu Bar / Frame and the problem does not happen there. The main difference is that in the GTK example, there is no explicit call to gtk_widget_destroy()


--
TT-Solutions: wxWidgets consultancy and technical support
              http://www.tt-solutions.com/

Julian Smart

unread,
May 4, 2012, 6:31:03 AM5/4/12
to wx-u...@googlegroups.com
On 04/05/2012 10:58, Eran Ifrah wrote:
>
> Just an FYI:
> I compiled GTK sample (
> http://www.gtk.org/tutorial1.2/gtk_tut-13.html#ss13.2 ) for Menu Bar /
> Frame and the problem does not happen there. The main difference is
> that in the GTK example, there is no explicit call to gtk_widget_destroy()
Also FYI, Jutoh compiled with wxWidgets 2.8.12 gives no warnings on
Ubuntu 12.04 when running and exiting, in case it helps to compare 2.8
and 2.9. (I had rather expected all kinds of Unity-related problems on
12.04 but was pleasantly surprised, and 12.04 runs nicely in VMware too.)

Regards,

Julian

--
Julian Smart, Anthemion Software Ltd.
www.anthemion.co.uk | +44 (0)131 229 5306
Tools for writers: www.writerscafe.co.uk
Ebook creation: www.jutoh.com
wxWidgets RAD: www.dialogblocks.com

Vadim Zeitlin

unread,
May 4, 2012, 11:19:43 AM5/4/12
to wx-u...@googlegroups.com
On Fri, 4 May 2012 12:58:02 +0300 Eran Ifrah wrote:

EI> I compiled GTK sample (
EI> http://www.gtk.org/tutorial1.2/gtk_tut-13.html#ss13.2 ) for Menu Bar /
EI> Frame and the problem does not happen there. The main difference is that in
EI> the GTK example, there is no explicit call to gtk_widget_destroy()

Yes, it's not necessary to destroy it explicitly but OTOH I don't know why
should it fail neither. Still, if there is no other way to avoid this
warning, perhaps we should prevent wxWindow dtor from doing it by calling
g_object_unref(m_widget) and setting m_widget to NULL in the dtor of
wxMenuBar itself.

Could you please test if doing this doesn't result in any new memory leaks
with Valgrind?

Thanks,
VZ

Eran Ifrah

unread,
May 7, 2012, 2:30:42 AM5/7/12
to wx-u...@googlegroups.com
On Fri, May 4, 2012 at 6:19 PM, Vadim Zeitlin <va...@wxwidgets.org> wrote:
On Fri, 4 May 2012 12:58:02 +0300 Eran Ifrah wrote:

EI> I compiled GTK sample (
EI> http://www.gtk.org/tutorial1.2/gtk_tut-13.html#ss13.2 ) for Menu Bar /
EI> Frame and the problem does not happen there. The main difference is that in
EI> the GTK example, there is no explicit call to gtk_widget_destroy()

 Yes, it's not necessary to destroy it explicitly but OTOH I don't know why
should it fail neither. Still, if there is no other way to avoid this
warning, perhaps we should prevent wxWindow dtor from doing it by calling
g_object_unref(m_widget) and setting m_widget to NULL in the dtor of
wxMenuBar itself.

I added a d-tor to wxMenuBar (there was none available) in include/wx/gtk/menu.h
and added the following code to it:

    if (m_widget)
    {
        // Release our reference and set m_widget to NULL this is to avoid freeing the widget again in the d-tor of wxWindow
        g_object_unref(m_widget);
        m_widget = NULL;
    }
 
This fixed the warnings when exiting the minimal sample

I also ran valgrind and compared the output before and after the patch, I did not notice any new memory leak
Attached is the patch



 Could you please test if doing this doesn't result in any new memory leaks
with Valgrind?

 Thanks,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
              http://www.tt-solutions.com/
gtk-menu.patch

Vadim Zeitlin

unread,
May 7, 2012, 7:13:01 AM5/7/12
to wx-u...@googlegroups.com
On Mon, 7 May 2012 09:30:42 +0300 Eran Ifrah wrote:

EI> I added a d-tor to wxMenuBar (there was none available)
EI> in include/wx/gtk/menu.h
EI> and added the following code to it:
EI>
EI> if (m_widget)
EI> {
EI> // Release our reference and set m_widget to NULL this is to avoid
EI> freeing the widget again in the d-tor of wxWindow
EI> g_object_unref(m_widget);
EI> m_widget = NULL;
EI> }
EI>
EI> This fixed the warnings when exiting the minimal sample
EI>
EI> I also ran valgrind and compared the output before and after the patch, I
EI> did not notice any new memory leak

Great, thanks for the patch and testing. I'd love to have Paul's opinion
about this before applying it but he's not there right now so I'll wait
until he gets back. Could you please open a ticket with this patch on Trac?
Like this we'll be certain to not forget to apply this before 2.9.4.

Thanks again,

Eran Ifrah

unread,
May 11, 2012, 3:38:07 AM5/11/12
to wx-u...@googlegroups.com
On Mon, May 7, 2012 at 2:13 PM, Vadim Zeitlin <va...@wxwidgets.org> wrote:
On Mon, 7 May 2012 09:30:42 +0300 Eran Ifrah wrote:

EI> I added a d-tor to wxMenuBar (there was none available)
EI> in include/wx/gtk/menu.h
EI> and added the following code to it:
EI>
EI>     if (m_widget)
EI>     {
EI>         // Release our reference and set m_widget to NULL this is to avoid
EI> freeing the widget again in the d-tor of wxWindow
EI>         g_object_unref(m_widget);
EI>         m_widget = NULL;
EI>     }
EI>
EI> This fixed the warnings when exiting the minimal sample
EI>
EI> I also ran valgrind and compared the output before and after the patch, I
EI> did not notice any new memory leak

 Great, thanks for the patch and testing. I'd love to have Paul's opinion
about this before applying it but he's not there right now so I'll wait
until he gets back. Could you please open a ticket with this patch on Trac?
Like this we'll be certain to not forget to apply this before 2.9.4.
 
Sorry for the late response,


 Thanks again,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
              http://www.tt-solutions.com/
Reply all
Reply to author
Forward
0 new messages