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 98869 - Mismatched new [] / delete.
Mismatched new [] / delete.
Status: RESOLVED FIXED
Product: libgnomeuimm
Classification: Other
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2002-11-18 13:43 UTC by Matthew Tuck
Modified: 2011-01-16 23:41 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix. (1.06 KB, patch)
2002-12-16 14:50 UTC, Matthew Tuck
none Details | Review

Description Matthew Tuck 2002-11-18 13:43:27 UTC
Valgrind reports the following error:

==17137== Mismatched free() / delete / delete []
==17137==    at 0x40045A12: __builtin_delete
(/home/cyrille/Code/2002/packages/my-packages/valgrind-1.0.4/vg_clientfuncs.c:194)
==17137==    by 0x40045A39: operator delete(void*)
(/home/cyrille/Code/2002/packages/my-packages/valgrind-1.0.4/vg_clientfuncs.c:203)
==17137==    by 0x402BE47F: Gnome::UI::Items::Info_::~Info_()
(../../libgnomeui/libgnomeuimm/app-helper.h:254)
==17137==    by 0x402BE531: Gnome::UI::Items::Info_::unref() (app-helper.cc:81)
==17137==    by 0x402BE7E1: Gnome::UI::Items::Info::~Info() (app-helper.cc:166)
==17137==    by 0x402AC0AA: Gnome::UI::App::~App() (app.cc:194)
==17137==    by 0x4025E341: Bakery::App::~App() (App.cc:69)
==17137==    by 0x40262060: Bakery::App_WithDoc::~App_WithDoc()
(App_WithDoc.cc:68)
==17137==    by 0x8125EA0: MainWindow::~MainWindow() (gnome_mainwindow.cc:46)
==17137==    by 0x4026642B:
Bakery::AppInstanceManager::on_app_hide(Bakery::App*)
(AppInstanceManager.cc:53)
==17137==    by 0x402669F8: ???
(/usr/local/include/sigc++-1.2/sigc++/object_slot.h:88)
==17137==    by 0x40266A1C: ???
(/usr/local/include/sigc++-1.2/sigc++/bind.h:153)
==17137==    by 0x4074D056:
Glib::SignalProxyNormal::slot0_void_callback(_GObject*, void*)
(signalproxy.cc:101)
==17137==    by 0x40D1B786: g_cclosure_marshal_VOID__VOID
(/tmp/buildd/glib2.0-2.0.7/build-tree/glib-2.0.7/gobject/gmarshal.c:79)
==17137==    by 0x40D06E1B: g_closure_invoke
(/tmp/buildd/glib2.0-2.0.7/build-tree/glib-2.0.7/gobject/gclosure.c:442)
==17137==    by 0x40D1AF5C: signal_emit_unlocked_R
(/tmp/buildd/glib2.0-2.0.7/build-tree/glib-2.0.7/gobject/gsignal.c:2184)
==17137==    by 0x40D191FA: g_signal_emit_valist
(/tmp/buildd/glib2.0-2.0.7/build-tree/glib-2.0.7/gobject/gsignal.c:2104)
==17137==    by 0x40950FAF: gtk_signal_emit
(/tmp/buildd/gtk+2.0-2.0.8/build-tree/gtk+-2.0.8/gtk/gtksignal.c:357)
==17137==    by 0x409CF38E: gtk_widget_hide
(/tmp/buildd/gtk+2.0-2.0.8/build-tree/gtk+-2.0.8/gtk/gtkwidget.c:1715)
==17137==    by 0x4061E350: Gtk::Widget::hide() (widget.cc:5006)
==17137==    by 0x40262935: Bakery::App_WithDoc::on_menu_File_Close()
(App_WithDoc.cc:100)
==17137==    by 0x81260A9: MainWindow::on_menu_File_Close()
(gnome_mainwindow.cc:84)
==17137==    by 0x4025EBB2: Bakery::App::on_delete_event(_GdkEventAny*)
(App.cc:121)
==17137==    by 0x4061C480:
Gtk::Widget_Class::delete_event_callback(_GtkWidget*, _GdkEventAny*)
(widget.cc:3757)
==17137==    by 0x4091BD72: _gtk_marshal_BOOLEAN__BOXED
(/tmp/buildd/gtk+2.0-2.0.8/build-tree/gtk+-2.0.8/gtk/gtkmarshalers.c:86)
==17137==    by 0x40D071F5: g_type_class_meta_marshal
(/tmp/buildd/glib2.0-2.0.7/build-tree/glib-2.0.7/gobject/gclosure.c:514)
==17137==    by 0x40D06E1B: g_closure_invoke
(/tmp/buildd/glib2.0-2.0.7/build-tree/glib-2.0.7/gobject/gclosure.c:442)
==17137==    by 0x40D1AD7A: signal_emit_unlocked_R
(/tmp/buildd/glib2.0-2.0.7/build-tree/glib-2.0.7/gobject/gsignal.c:2184)
==17137==    by 0x40D19267: g_signal_emit_valist
(/tmp/buildd/glib2.0-2.0.7/build-tree/glib-2.0.7/gobject/gsignal.c:2114)
==17137==    by 0x40950FAF: gtk_signal_emit
(/tmp/buildd/gtk+2.0-2.0.8/build-tree/gtk+-2.0.8/gtk/gtksignal.c:357)
==17137==    by 0x409D13BD: gtk_widget_event_internal
(/tmp/buildd/gtk+2.0-2.0.8/build-tree/gtk+-2.0.8/gtk/gtkwidget.c:3082)
==17137==    by 0x409D1020: gtk_widget_event
(/tmp/buildd/gtk+2.0-2.0.8/build-tree/gtk+-2.0.8/gtk/gtkwidget.c:2943)
==17137==    by 0x4091AB49: gtk_main_do_event
(/tmp/buildd/gtk+2.0-2.0.8/build-tree/gtk+-2.0.8/gtk/gtkmain.c:1304)
==17137==    by 0x40A9A0DC: gdk_event_dispatch
(/tmp/buildd/gtk+2.0-2.0.8/build-tree/gtk+-2.0.8/gdk/x11/gdkevents-x11.c:1778)
==17137==    by 0x40D75B29: g_main_dispatch
(/tmp/buildd/glib2.0-2.0.7/build-tree/glib-2.0.7/glib/gmain.c:1645)
==17137==    by 0x40D76947: g_main_context_dispatch
(/tmp/buildd/glib2.0-2.0.7/build-tree/glib-2.0.7/glib/gmain.c:2190)
==17137==    by 0x40D76D23: g_main_context_iterate
(/tmp/buildd/glib2.0-2.0.7/build-tree/glib-2.0.7/glib/gmain.c:2270)
==17137==    by 0x40D773FF: g_main_loop_run
(/tmp/buildd/glib2.0-2.0.7/build-tree/glib-2.0.7/glib/gmain.c:2490)
==17137==    by 0x4091A33F: gtk_main
(/tmp/buildd/gtk+2.0-2.0.8/build-tree/gtk+-2.0.8/gtk/gtkmain.c:968)
==17137==    by 0x405D26C2: Gtk::Main::run_impl() (main.cc:471)
==17137==    by 0x405D24BD: Gtk::Main::run() (main.cc:417)
==17137==    by 0x81540F4: main (gnome_main.cc:33)
==17137==    by 0x40F509D3: __libc_start_main (in /lib/libc-2.3.1.so)
==17137==    by 0x80DDB71: (within /home/matty/Projects/Visage-0.1/src/visage)


==17137==    Address 0x46707508 is 0 bytes inside a block of size 6 alloc'd


==17137==    at 0x400458A8: __builtin_vec_new
(/home/cyrille/Code/2002/packages/my-packages/valgrind-1.0.4/vg_clientfuncs.c:156)
==17137==    by 0x400458F1: operator new[](unsigned)
(/home/cyrille/Code/2002/packages/my-packages/valgrind-1.0.4/vg_clientfuncs.c:169)
==17137==    by 0x402BDFB6: Gnome::UI::Items::cpp_strdup(Glib::ustring
const&) (app-helper.cc:43)
==17137==    by 0x402BE25C: Gnome::UI::Items::Info_::Info_(Glib::ustring
const&, Glib::ustring const&) (app-helper.cc:60)
==17137==    by 0x402BEB45:
Gnome::UI::Items::Info::init_cbw(Gnome::UI::Items::Info::Type,
Gnome::UI::Items::Icon const&, Glib::ustring const&, SigC::Slot1<void,
Gtk::Widget*> const&, Glib::ustring const&) (app-helper.cc:265)
==17137==    by 0x40262589: Bakery::App_WithDoc::init_toolbars()
(/usr/local/include/libgnomeuimm-2.0/libgnomeuimm/app-helper.h:382)
==17137==    by 0x4025E72D: Bakery::App::init() (App.cc:83)
==17137==    by 0x402640A8: Bakery::App_WithDoc::init() (App_WithDoc.cc:411)
==17137==    by 0x81263C7: MainWindow::init() (gnome_mainwindow.cc:121)
==17137==    by 0x81540EC: main (gnome_main.cc:29)
==17137==    by 0x40F509D3: __libc_start_main (in /lib/libc-2.3.1.so)
==17137==    by 0x80DDB71: (within /home/matty/Projects/Visage-0.1/src/visage)

According to the Valgrind docs, if you allocate with new [] you must
deallocated with delete [], not delete.
Comment 1 Murray Cumming 2002-11-18 20:11:54 UTC
How can we reproduce this error? Does this happen on any of the
gnomemm examples, or only your own app?
Comment 2 Matthew Tuck 2002-11-19 04:00:35 UTC
I will see about getting a test case.  I couldn't replace it on
examples/menu, and examples/gnome-hello is broken.
Comment 3 Murray Cumming 2002-12-16 13:41:59 UTC
Any chance of that test case?
Comment 4 Matthew Tuck 2002-12-16 14:44:36 UTC
This is a pretty simple fix, Info_() uses cpp_strdup which uses new
[], whereas ~Info() uses delete.  I'm about to attach a patch for this.
Comment 5 Matthew Tuck 2002-12-16 14:50:41 UTC
Created attachment 13035 [details] [review]
Fix.
Comment 6 Murray Cumming 2002-12-17 15:00:50 UTC
Excellent. Well done.