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 107584 - libbonoboui "hello" example segfault on quit
libbonoboui "hello" example segfault on quit
Status: RESOLVED FIXED
Product: gnomemm
Classification: Deprecated
Component: libbonobouimm
2.0
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2003-03-04 21:19 UTC by Bryan Forbes
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Here's the test case.... (1.23 KB, application/x-compressed-tar)
2003-03-07 18:22 UTC, Bryan Forbes
  Details
Correct order of destruction and perform object deactivation (ugly and leaks memory/references). (1.33 KB, patch)
2003-11-11 22:03 UTC, Bowie Owens
none Details | Review

Description Bryan Forbes 2003-03-04 21:19:56 UTC
Ok, the hello example (libbonobouimm/examples/hello) works fine except for
if you click on the window manager's X to close the window it segfaults. 
Here's the backtrace:

  • #0 ??
  • #1 POA_Bonobo::UIComponent::_skel_unsetContainer(void*, CORBA_Environment_type*)
    at Bonobo-cpp-skels.cc line 2949
  • #2 Bonobo_UIComponent_unsetContainer
    at Bonobo-stubs.c line 1870
  • #3 sub_component_destroy
    at bonobo-ui-engine.c line 788
  • #4 bonobo_ui_engine_dispose
    at bonobo-ui-engine.c line 1833
  • #5 bonobo_window_dispose
    at bonobo-window.c line 140
  • #6 Gtk::Widget_Class::dispose_vfunc_callback(_GObject*)
    at widget.cc line 305
  • #7 g_object_run_dispose
    at gobject.c line 474
  • #8 gtk_object_destroy
    at gtkobject.c line 361
  • #9 Gtk::Window::_destroy_c_instance()
    at window.cc line 126
  • #10 Gtk::Window::destroy_()
    at window.cc line 91
  • #11 ~Window
    at window.cc line 122
  • #12 ~HelloWindow
    at /opt/gnome2/include/gtkmm-2.0/glibmm/helperlist.h line 150

Comment 1 Bryan Forbes 2003-03-04 21:22:32 UTC
forgot the last line of the bt:
  • #13 main
    at main.cc line 46

Comment 2 Bryan Forbes 2003-03-04 21:27:19 UTC
all my libraries are the latest anoncvs
Comment 3 Murray Cumming 2003-03-06 16:02:09 UTC
My first step would be to comment parts of the example out until I had
a simple-as-possible-but-still-crashing example.
Comment 4 Bryan Forbes 2003-03-07 18:17:46 UTC
Ok, I isolated the problem to line 43 of hellowindow.cc of the hello
example.  I made my own application (a slimmed down version of the
hello example) to demonstrate this.  Compile it with this command:
g++ -ggdb *.cc `pkg-config libgnomeuimm-2.0 --cflags --libs` -o test

then run test and click the WM's X.  It will segfault.

This example takes all comments out of the hello example and brings in
no XML.  The culprit line is line 11.  Hope this helps!
Comment 5 Bryan Forbes 2003-03-07 18:22:27 UTC
Created attachment 14841 [details]
Here's the test case....
Comment 6 Bryan Forbes 2003-03-07 18:24:06 UTC
save the attachment as hello_isolated.tar.gz
Comment 7 Murray Cumming 2003-03-15 15:31:03 UTC
Confirmed. The example segfaults on quit for me too.
Comment 8 Murray Cumming 2003-05-19 06:19:16 UTC
I need to check this with the latest orbitcpp from cvs - there have
been some lifetime changes. But the orbitcpp from cvs doesn't work
with libbonobomm. Stay tuned. I just wanted to say I hadn't forgotten
this.
Comment 9 Murray Cumming 2003-06-15 16:28:41 UTC
Could you check with the latest orbitcpp again?
Comment 10 Bryan Forbes 2003-06-15 19:25:32 UTC
Yes, it still segfaults.  If you need a new backtrace, I can provide
it.  Thanks for checking this all out for me Murray.  Hopefully, soon,
I'll be able to figure it out after dealing with vfs stuff :).
Comment 11 Murray Cumming 2003-07-15 07:04:06 UTC
I finally built the latest cvs orbit and libbonobouimm and this bug
still exists.
Comment 12 Bowie Owens 2003-11-11 05:39:59 UTC
There are two problems with the example. First, the UIComponent_impl
HelloWindow::m_servantComponent is destructed before the
Gnome::Bonobo::Window base class. The destruction of the base class
attempts to call methods on the m_servantComponent resulting in the
segmentation fault you are getting. Next, the m_servantComponent is
activiated in the Root POA but never deactivated. When program exits
ORBit tries to clean up all still active objects. Again resulting in a
seg fault. Thus the simplest and most hackish way to fix the problem
is to new allocate the HelloWindow object and never delete it. I
haven't got my head around the correct way to fix these two problems.
Comment 13 Bowie Owens 2003-11-11 22:03:41 UTC
Created attachment 21368 [details] [review]
Correct order of destruction and perform object deactivation (ugly and leaks memory/references).
Comment 14 Bowie Owens 2003-11-11 22:18:13 UTC
Hi,

I have just added a patch that reorders the destruction of members and
bases and deactivates the servant object before destroying it. The
result is very ugly. To do this nicely I suggest we add a class
template to bonobomm: 

// Encapsulate ownership of a single servant and automatically
// deactivate in bonobo POA at end of lifetime.
template <class S>
class ServantOwner {
protected:
        S m_servant;
        ~ServantOwner()
        {
                _orbitcpp::CEnvironment env;
                PortableServer_POA poa = bonobo_poa();
                                                                     
          
                PortableServer_Servant servant =
m_servant._orbitcpp_get_c_servant();
                PortableServer_ObjectId* oid =
PortableServer_POA_servant_to_id(poa, servant, env._orbitcpp_cobj());
                env.propagate_poaex();
                PortableServer_POA_deactivate_object(poa, oid,
env._orbitcpp_cobj());
                env.propagate_poaex();
        }
};