Bug #55776 System.NullReferenceException|Object reference not set to an instance of object
Submitted: 5 Aug 2010 11:02 Modified: 16 Aug 2010 4:12
Reporter: Roel Van de Paar (OCA) Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Workbench: Modeling Severity:S1 (Critical)
Version:5.2.26pre3, 5.2.26 OS:Any
Assigned to: CPU Architecture:Any

[5 Aug 2010 11:02] Roel Van de Paar
Description:
Exception = System.NullReferenceException
Message = Object reference not set to an instance of an object.
FullText = System.NullReferenceException: Object reference not set to an instance of an object.
   at Aga.Controls.Tree.TreeViewAdv.ReadChilds(TreeNodeAdv parentNode, Boolean performFullUpdate)
   at Aga.Controls.Tree.TreeViewAdv._model_StructureChanged(Object sender, TreePathEventArgs e)
   at MySQL.Grt.GrtListModel.OnStructureChanged(TreePathEventArgs args)
   at MySQL.Grt.GrtListModel.RefreshModel()
   at MySQL.GUI.Workbench.UndoHistoryForm.UpdateHistoryTree()
   at MySQL.GUI.Workbench.UndoHistoryForm.invokeRefresh(NodeId node, Int32 oldCount)
   at MySQL.Grt.RunWrappedDelegate2<void\,void\,bec::NodeId\,MySQL::Grt::NodeId ^\,int\,int\,MySQL::Grt::DelegateSlot2<void\,void\,bec::NodeId\,MySQL::Grt::NodeId ^\,int\,int>::ManagedDelegate>.native_callback(NodeId* a1, Int32* a2)
   at sigc.pointer_functor2<bec::NodeId const &,int const &,void>.()(pointer_functor2<bec::NodeId const \&\,int const \&\,void>* , NodeId* _A_a1, Int32* _A_a2)
   at sigc.adaptor_functor<sigc::pointer_functor2<bec::NodeId const &,int const &,void> >.operator()<struct bec::NodeId const &,int const &>(adaptor_functor<sigc::pointer_functor2<bec::NodeId const \&\,int const \&\,void> >* , NodeId* _A_arg1, Int32* _A_arg2)
   at sigc.internal.slot_call2<sigc::pointer_functor2<bec::NodeId const &,int const &,void>,void,bec::NodeId const &,int const &>.call_it(slot_rep* rep, NodeId* a_1, Int32* a_2)
   at sigc.slot2<void,bec::NodeId const &,int const &>.()(slot2<void\,bec::NodeId const \&\,int const \&>* , NodeId* _A_a1, Int32* _A_a2)
   at sigc.adaptor_functor<sigc::slot<void,bec::NodeId const &,int const &,sigc::nil,sigc::nil,sigc::nil,sigc::nil,sigc::nil> >.operator()<struct bec::NodeId const &,int const &>(adaptor_functor<sigc::slot<void\,bec::NodeId const \&\,int const \&\,sigc::nil\,sigc::nil\,sigc::nil\,sigc::nil\,sigc::nil> >* , NodeId* _A_arg1, Int32* _A_arg2)
   at sigc.internal.slot_call2<sigc::slot<void,bec::NodeId const &,int const &,sigc::nil,sigc::nil,sigc::nil,sigc::nil,sigc::nil>,void,bec::NodeId,int>.call_it(slot_rep* rep, NodeId* a_1, Int32* a_2)

How to repeat:
Clicking around EER's. This time I made a video so let's see if I can find what did it :). Adding backtrace shortly.
[5 Aug 2010 11:30] Roel Van de Paar
Note I used symbols from 5.2.25 to resolve stack. If they are no longer correct, let me know.

Attachment: backtrace_bug_55776.txt (text/plain), 25.66 KiB.

[6 Aug 2010 2:53] Roel Van de Paar
Have been able to reproduce once. Setting verified based on that. Still working on an easy reproducible testcase. It has something to do with the "multiple selections" option in "description editor" in "mysql model". For instance: select CTRL-A to select a set of tables in a model, right-click and paste and before the paste finishes (make sure you have enough tables) click on "mysql model" - notice that it now shows "multiple selections" in the "description editor" while being in the wrong tab ("mysql model" instead of "EER diagram"). Combined with some other things, I believe this is where the issue is.
[8 Aug 2010 23:15] Roel Van de Paar
Another similar crash today

Exception = System.NullReferenceException
Message = Object reference not set to an instance of an object.
FullText = System.NullReferenceException: Object reference not set to an instance of an object.
   at Aga.Controls.Tree.TreeNodeAdv.NodeCollection.RemoveItem(Int32 index)
   at System.Collections.ObjectModel.Collection`1.RemoveAt(Int32 index)
   at Aga.Controls.Tree.TreeNodeAdv.NodeCollection.ClearItems()
   at System.Collections.ObjectModel.Collection`1.Clear()
   at Aga.Controls.Tree.TreeViewAdv.ReadChilds(TreeNodeAdv parentNode, Boolean performFullUpdate)
   at Aga.Controls.Tree.TreeViewAdv._model_StructureChanged(Object sender, TreePathEventArgs e)
   at MySQL.Grt.GrtListModel.OnStructureChanged(TreePathEventArgs args)
   at MySQL.Grt.GrtListModel.RefreshModel()
   at MySQL.GUI.Workbench.UndoHistoryForm.UpdateHistoryTree()
   at MySQL.GUI.Workbench.UndoHistoryForm.invokeRefresh(NodeId node, Int32 oldCount)
   at MySQL.Grt.RunWrappedDelegate2<void\,void\,bec::NodeId\,MySQL::Grt::NodeId ^\,int\,int\,MySQL::Grt::DelegateSlot2<void\,void\,bec::NodeId\,MySQL::Grt::NodeId ^\,int\,int>::ManagedDelegate>.native_callback(NodeId* a1, Int32* a2)
   at sigc.pointer_functor2<bec::NodeId const &,int const &,void>.()(pointer_functor2<bec::NodeId const \&\,int const \&\,void>* , NodeId* _A_a1, Int32* _A_a2)
   at sigc.adaptor_functor<sigc::pointer_functor2<bec::NodeId const &,int const &,void> >.operator()<struct bec::NodeId const &,int const &>(adaptor_functor<sigc::pointer_functor2<bec::NodeId const \&\,int const \&\,void> >* , NodeId* _A_arg1, Int32* _A_arg2)
   at sigc.internal.slot_call2<sigc::pointer_functor2<bec::NodeId const &,int const &,void>,void,bec::NodeId const &,int const &>.call_it(slot_rep* rep, NodeId* a_1, Int32* a_2)
   at sigc.slot2<void,bec::NodeId const &,int const &>.()(slot2<void\,bec::NodeId const \&\,int const \&>* , NodeId* _A_a1, Int32* _A_a2)
   at sigc.adaptor_functor<sigc::slot<void,bec::NodeId const &,int const &,sigc::nil,sigc::nil,sigc::nil,sigc::nil,sigc::nil> >.operator()<struct bec::NodeId const &,int const &>(adaptor_functor<sigc::slot<void\,bec::NodeId const \&\,int const \&\,sigc::nil\,sigc::nil\,sigc::nil\,sigc::nil\,sigc::nil> >* , NodeId* _A_arg1, Int32* _A_arg2)
   at sigc.internal.slot_call2<sigc::slot<void,bec::NodeId const &,int const &,sigc::nil,sigc::nil,sigc::nil,sigc::nil,sigc::nil>,void,bec::NodeId,int>.call_it(slot_rep* rep, NodeId* a_1, Int32* a_2)
   at wb.WBContextUI.set_active_form(WBContextUI* , UIForm* )
   at MySQL.Workbench.WbContext.set_active_form(UIForm uiform)
   at MySQL.GUI.Workbench.MainForm.tabControl_SelectedIndexChanged(Object sender, EventArgs e)
   at System.Windows.Forms.TabControl.OnSelectedIndexChanged(EventArgs e)
   at MySQL.Controls.FlatTabControl.OnSelectedIndexChanged(EventArgs e)
   at System.Windows.Forms.TabControl.WmSelChange()
   at System.Windows.Forms.TabControl.set_SelectedIndex(Int32 value)
   at System.Windows.Forms.TabControl.set_SelectedTab(TabPage value)
   at MySQL.Controls.TabDocument.Activate()
   at MySQL.GUI.Workbench.MainForm.DockDocument(ITabDocument document, Boolean main, Boolean activate)
   at MySQL.GUI.Workbench.MainForm.RefreshGUI(RefreshType refresh, String str, IntPtr ptr)
   at MySQL.Workbench.WbFrontendCallbacks.refresh_gui_wrapper(RefreshType refresh, basic_string<char\,std::char_traits<char>\,std::allocator<char> >* str, Int64 ptr)
   at sigc.pointer_functor3<enum wb::RefreshType,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,__int64,void>.()(pointer_functor3<enum wb::RefreshType\,std::basic_string<char\,std::char_traits<char>\,std::allocator<char> > const \&\,__int64\,void>* , RefreshType* _A_a1, basic_string<char\,std::char_traits<char>\,std::allocator<char> >* _A_a2, Int64* _A_a3)
   at sigc.adaptor_functor<sigc::pointer_functor3<enum wb::RefreshType,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,__int64,void> >.operator()<enum wb::RefreshType const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,__int64 const &>(adaptor_functor<sigc::pointer_functor3<enum wb::RefreshType\,std::basic_string<char\,std::char_traits<char>\,std::allocator<char> > const \&\,__int64\,void> >* , RefreshType* _A_arg1, basic_string<char\,std::char_traits<char>\,std::allocator<char> >* _A_arg2, Int64* _A_arg3)
   at sigc.internal.slot_call3<sigc::pointer_functor3<enum wb::RefreshType,std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &,__int64,void>,void,enum wb::RefreshType,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,__int64>.call_it(slot_rep* rep, RefreshType* a_1, basic_string<char\,std::char_traits<char>\,std::allocator<char> >* a_2, Int64* a_3)
   at wb.WBContext.flush_idle_tasks(WBContext* )
   at MySQL.Workbench.WbContext.flush_idle_tasks()
   at MySQL.GUI.Workbench.Program.timer_Tick(Object sender, EventArgs e)
[8 Aug 2010 23:19] Roel Van de Paar
See bug #55774
[16 Aug 2010 1:37] Roel Van de Paar
I was able to reproduce this once using the automatic test suite I am creating while doing some testing for bug #55304. Uploading video soon.
[16 Aug 2010 1:42] Roel Van de Paar
Backtrace from last crash. Some interesting items (ref note below)

Attachment: backtrace from MySQLWorkbench.DMP.txt (text/plain), 30.63 KiB.

[16 Aug 2010 2:02] Roel Van de Paar
Note this, very interesting from the dump: "Invalid window handle":

And, as you can see from the video below, this was after deleting some EER diagrams.

0:000:x86> !gle -all
Last error for thread 0:
LastErrorValue: (Win32) 0 (0) - The operation completed successfully.
LastStatusValue: (NTSTATUS) 0xc0000008 - An invalid HANDLE was specified.
[...]
Last error for thread 6:
LastErrorValue: (Win32) 0x578 (1400) - Invalid window handle.
LastStatusValue: (NTSTATUS) 0 - STATUS_WAIT_0
[...]
Last error for thread 7:
LastErrorValue: (Win32) 0 (0) - The operation completed successfully.
LastStatusValue: (NTSTATUS) 0xc0000008 - An invalid HANDLE was specified.
[16 Aug 2010 4:12] Roel Van de Paar
I am quite convinced that the following bugs:

bug #55304 | bug #55776 | bug #55904 | bug #55774 | bug #55828 | bug #55996

all have the same cause: some sort of issue with window/tab handles (note the "An invalid HANDLE was specified."). 

For more information, see the "[16 Aug 5:30] Roel Van de Paar" comment in bug #55996.

I am marking this bug as a duplicate of bug #55304 as that was the main one in which this issue was handled.