GNOME Bugzilla – Bug 93577
valgrind detects illegal read access during Gtk::Main destruction
Last modified: 2004-12-22 21:47:04 UTC
program: #include <gtkmm.h> int main(int argc, char ** argv){ Gtk::Main kit(argc,argv); Gtk::Window* win=new Gtk::Window(); kit.run(*win); return 0; } Compiles correctly, runs correctly (pops up window, exits when window is closed) When running under valgrind, an invalid read is detected. GDB backtrace:
+ Trace 27458
This happens (obviously) after pressing the close button. However, the program exits normally. Tassos
Confirmed on RH7.2 with gcc 2.96.
Here's some fuller information, using --num-callers=20. This shows what freed the memory that is being incorrectly read again later. ==25837== Invalid read of size 4 ==25837== at 0x404F7E85: SigC::Control_::destroy(void) (object.cc:72) ==25837== by 0x404F8020: SigC::ObjectBase::~ObjectBase(void) (object.cc:117) ==25837== by 0x4044BD2C: Gtk::Main::~Main(void) (main.cc:360) ==25837== by 0x8048CAC: main (main.cc:7) ==25837== by 0x40938507: __libc_start_main (../sysdeps/generic/libc-start.c:129) ==25837== by 0x8048B81: Gtk::Main::Main(int, int &, char **&, bool) (in /gnome/gnome-2-0/cvs/c++/gtkmm-1.3/tests/delete_cpp_child/.libs/lt-test) ==25837== by <bogus frame pointer> ??? ==25837== by <bogus frame pointer> ??? ==25837== Address 0x41F8BD3C is 36 bytes inside a block of size 44 free'd ==25837== at 0x40040729: __builtin_delete (vg_clientfuncs.c:186) ==25837== by 0x404F7C6E: SigC::ObjectSlotNode::~ObjectSlotNode(void) (object_slot.cc:31) ==25837== by 0x404F7077: SigC::Node::clear(void) const (node.cc:47) ==25837== by 0x404F7290: SigC::SlotNode::notify(bool) (slot.cc:78) ==25837== by 0x404F7C0F: SigC::ObjectSlotNode::notify(bool) (object_slot.cc:24) ==25837== by 0x404F7E85: SigC::Control_::destroy(void) (object.cc:72) ==25837== by 0x404F8020: SigC::ObjectBase::~ObjectBase(void) (object.cc:117) ==25837== by 0x4044BD2C: Gtk::Main::~Main(void) (main.cc:360) ==25837== by 0x8048CAC: main (main.cc:7) ==25837== by 0x40938507: __libc_start_main (../sysdeps/generic/libc-start.c:129) ==25837== by 0x8048B81: Gtk::Main::Main(int, int &, char **&, bool) (in /gnome/gnome-2-0/cvs/c++/gtkmm-1.3/tests/delete_cpp_child/.libs/lt-test) ==25837== by <bogus frame pointer> ??? ==25837== by <bogus frame pointer> ???
This doesn't happen if you delete the Gtk::Window before the end of main(). And you should do that. So I don't think this is a bug.
Do you agree?
<ponders>... Ok.