Author Topic: Crash in revision 3412 when disabling plugin  (Read 7212 times)

Offline Der Meister

  • Regular
  • ***
  • Posts: 307
Crash in revision 3412 when disabling plugin
« on: December 22, 2006, 02:47:08 pm »
I just tried to disable the file extension handler plugin but then Code::Blocks immediately crashes. I did not test if this happens with other plugins, too.
Here is the full backtrace I got from gdb:
Quote
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1232230736 (LWP 13355)]
0xb7cd3447 in MenuItemsManager::Clear (this=0x84e97d0) at menuitemsmanager.cpp:88
88                  if (!subMenu || subMenu->GetMenuItemCount() == 0)
(gdb) bt                       
#0  0xb7cd3447 in MenuItemsManager::Clear (this=0x84e97d0) at menuitemsmanager.cpp:88
#1  0xb7d57aa3 in ToolsManager::BuildToolsMenu (this=0x84e9788, menu=0x87fa460) at toolsmanager.cpp:315
#2  0x08092180 in MainFrame::CreateMenubar (this=0x82cf160) at main.cpp:855
#3  0x08099022 in MainFrame::RecreateMenuBar (this=0x82cf160) at main.cpp:751
#4  0x0809918b in MainFrame::PluginsUpdated (this=0x82cf160, plugin=0x8ab0bd0, status=2) at main.cpp:691
#5  0x080996ff in MainFrame::OnPluginUnloaded (this=0x82cf160, event=@0xbffcf50c) at main.cpp:3481
#6  0xb753838b in wxAppConsole::HandleEvent () from /usr/lib/libwx_baseu-2.6.so.0
#7  0xb75da2f8 in wxEvtHandler::ProcessEventIfMatches () from /usr/lib/libwx_baseu-2.6.so.0
#8  0xb75da4af in wxEventHashTable::HandleEvent () from /usr/lib/libwx_baseu-2.6.so.0
#9  0xb75da710 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#10 0xb7c31154 in cbPlugin::Release (this=0x8ab0bd0, appShutDown=false) at cbplugin.cpp:95
#11 0xb7cf7b24 in PluginManager::DetachPlugin (this=0x8530be8, plugin=0x8ab0bd0) at pluginmanager.cpp:221
#12 0xb7d04fa4 in PluginsConfigurationDlg::OnToggle (this=0xbffd0b10, event=@0xbffcf970) at pluginsconfigurationdlg.cpp:199
#13 0xb753838b in wxAppConsole::HandleEvent () from /usr/lib/libwx_baseu-2.6.so.0
#14 0xb75da2f8 in wxEvtHandler::ProcessEventIfMatches () from /usr/lib/libwx_baseu-2.6.so.0
#15 0xb75da4fe in wxEventHashTable::HandleEvent () from /usr/lib/libwx_baseu-2.6.so.0
#16 0xb75da710 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#17 0xb7882138 in wxWindowBase::TryParent () from /usr/lib/libwx_gtk2u_core-2.6.so.0
#18 0xb75da6b9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#19 0xb77ce902 in wxButton::wxCreateObject () from /usr/lib/libwx_gtk2u_core-2.6.so.0
#20 0xb6e6ff4a in g_cclosure_marshal_VOID__VOID () from /usr/lib/libgobject-2.0.so.0
#21 0xb6e612d5 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#22 0xb6e73673 in g_signal_chain_from_overridden () from /usr/lib/libgobject-2.0.so.0
#23 0xb6e748a0 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#24 0xb6e74d09 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#25 0xb6f6a65c in gtk_button_clicked () from /usr/lib/libgtk-x11-2.0.so.0
#26 0xb6f6c179 in gtk_button_set_alignment () from /usr/lib/libgtk-x11-2.0.so.0
#27 0xb6e6ff4a in g_cclosure_marshal_VOID__VOID () from /usr/lib/libgobject-2.0.so.0
#28 0xb6e5f515 in g_value_set_boxed () from /usr/lib/libgobject-2.0.so.0
#29 0xb6e612d5 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#30 0xb6e7381f in g_signal_chain_from_overridden () from /usr/lib/libgobject-2.0.so.0
#31 0xb6e748a0 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#32 0xb6e74d09 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#33 0xb6f6a6df in gtk_button_released () from /usr/lib/libgtk-x11-2.0.so.0
#34 0xb6f6a730 in gtk_button_released () from /usr/lib/libgtk-x11-2.0.so.0
#35 0xb702def2 in gtk_marshal_BOOLEAN__VOID () from /usr/lib/libgtk-x11-2.0.so.0
#36 0xb6e5f515 in g_value_set_boxed () from /usr/lib/libgobject-2.0.so.0
#37 0xb6e61555 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#38 0xb6e739d8 in g_signal_chain_from_overridden () from /usr/lib/libgobject-2.0.so.0
#39 0xb6e74662 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#40 0xb6e74d09 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#41 0xb712fec0 in gtk_widget_get_default_style () from /usr/lib/libgtk-x11-2.0.so.0
#42 0xb7027f9d in gtk_propagate_event () from /usr/lib/libgtk-x11-2.0.so.0
#43 0xb7028fc2 in gtk_main_do_event () from /usr/lib/libgtk-x11-2.0.so.0
#44 0xb728613b in gdk_add_client_message_filter () from /usr/lib/libgdk-x11-2.0.so.0
#45 0xb6dd4c6a in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#46 0xb6dd549b in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#47 0xb6dd5835 in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
#48 0xb702941c in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0
#49 0xb777760b in wxEventLoop::Run () from /usr/lib/libwx_gtk2u_core-2.6.so.0
#50 0xb77da52c in wxDialog::ShowModal () from /usr/lib/libwx_gtk2u_core-2.6.so.0
#51 0xb7cf781b in PluginManager::Configure (this=0x8530be8) at pluginmanager.cpp:1300
#52 0x0807c677 in MainFrame::OnSettingsPlugins (this=0x82cf160, event=@0xbffd10d0) at main.cpp:3528
#53 0xb753838b in wxAppConsole::HandleEvent () from /usr/lib/libwx_baseu-2.6.so.0
#54 0xb75da2f8 in wxEvtHandler::ProcessEventIfMatches () from /usr/lib/libwx_baseu-2.6.so.0
#55 0xb75da5c4 in wxEventHashTable::HandleEvent () from /usr/lib/libwx_baseu-2.6.so.0
#56 0xb75da710 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#57 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#58 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#59 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#60 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#61 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#62 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#63 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#64 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#65 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#66 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#67 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#68 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#69 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#70 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#71 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#72 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#73 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#74 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#75 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#76 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#77 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#78 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#79 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#80 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#81 0xb75da6a9 in wxEvtHandler::ProcessEvent () from /usr/lib/libwx_baseu-2.6.so.0
#82 0xb77e7d96 in wxMenuItem::~wxMenuItem () from /usr/lib/libwx_gtk2u_core-2.6.so.0
#83 0xb6e6ff4a in g_cclosure_marshal_VOID__VOID () from /usr/lib/libgobject-2.0.so.0
#84 0xb6e612d5 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#85 0xb6e733b2 in g_signal_chain_from_overridden () from /usr/lib/libgobject-2.0.so.0
#86 0xb6e748a0 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#87 0xb6e74d09 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#88 0xb7133dbe in gtk_widget_activate () from /usr/lib/libgtk-x11-2.0.so.0
#89 0xb7039fcc in gtk_menu_shell_activate_item () from /usr/lib/libgtk-x11-2.0.so.0
#90 0xb703b45a in gtk_menu_shell_append () from /usr/lib/libgtk-x11-2.0.so.0
#91 0xb70337bf in gtk_menu_reorder_child () from /usr/lib/libgtk-x11-2.0.so.0
#92 0xb702def2 in gtk_marshal_BOOLEAN__VOID () from /usr/lib/libgtk-x11-2.0.so.0
#93 0xb6e5f515 in g_value_set_boxed () from /usr/lib/libgobject-2.0.so.0
#94 0xb6e612d5 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#95 0xb6e739d8 in g_signal_chain_from_overridden () from /usr/lib/libgobject-2.0.so.0
#96 0xb6e74662 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#97 0xb6e74d09 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#98 0xb712fec0 in gtk_widget_get_default_style () from /usr/lib/libgtk-x11-2.0.so.0
#99 0xb7027f9d in gtk_propagate_event () from /usr/lib/libgtk-x11-2.0.so.0
#100 0xb7028fc2 in gtk_main_do_event () from /usr/lib/libgtk-x11-2.0.so.0
#101 0xb728613b in gdk_add_client_message_filter () from /usr/lib/libgdk-x11-2.0.so.0
#102 0xb6dd4c6a in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#103 0xb6dd549b in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#104 0xb6dd5835 in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
#105 0xb702941c in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0
#106 0xb777760b in wxEventLoop::Run () from /usr/lib/libwx_gtk2u_core-2.6.so.0
#107 0xb780409a in wxAppBase::MainLoop () from /usr/lib/libwx_gtk2u_core-2.6.so.0
#108 0xb78038d1 in wxAppBase::OnRun () from /usr/lib/libwx_gtk2u_core-2.6.so.0
#109 0x08068905 in CodeBlocksApp::OnRun (this=0x8112d98) at app.cpp:580
#110 0xb757af2a in wxEntry () from /usr/lib/libwx_baseu-2.6.so.0
#111 0xb757afd2 in wxEntry () from /usr/lib/libwx_baseu-2.6.so.0
#112 0x08066c90 in main (argc=Cannot access memory at address 0x43
) at app.cpp:188

I compiled Code::Blocks (revision 3412) with GCC 4.1.1 and wxGTK 2.6.2 on Linux.

Edit:
This crash does *not* happen if there is an open project. But if there is no open project it seems to crash if I disable any plugin, not just if I disable the file extension handler plugin.
« Last Edit: December 22, 2006, 03:09:29 pm by Der Meister »
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand.
Real Programmers don't write in BASIC. Actually, no programmers write in BASIC, after the age of 12.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5498
Re: Crash in revision 3412 when disabling plugin
« Reply #1 on: December 22, 2006, 10:12:50 pm »
seems very serious, could you post at berlios (when berlios is up again ;-) )

Offline Der Meister

  • Regular
  • ***
  • Posts: 307
Re: Crash in revision 3412 when disabling plugin
« Reply #2 on: December 23, 2006, 07:54:35 pm »
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand.
Real Programmers don't write in BASIC. Actually, no programmers write in BASIC, after the age of 12.

Online stahta01

  • Lives here!
  • ****
  • Posts: 7594
    • My Best Post
Re: Crash in revision 3412 when disabling plugin
« Reply #3 on: December 25, 2006, 12:16:05 am »
I just tried to disable the file extension handler plugin but then Code::Blocks immediately crashes. I did not test if this happens with other plugins, too.
Here is the full backtrace I got from gdb:

I compiled Code::Blocks (revision 3412) with GCC 4.1.1 and wxGTK 2.6.2 on Linux.

Edit:
This crash does *not* happen if there is an open project. But if there is no open project it seems to crash if I disable any plugin, not just if I disable the file extension handler plugin.

I have duplicated the issue under windows, but only about 1/3 of the plugins crash.
Note: If no contrib plugins are used the core ones do NOT have a problem.

Tim S
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Der Meister

  • Regular
  • ***
  • Posts: 307
Re: Crash in revision 3412 when disabling plugin
« Reply #4 on: December 27, 2006, 11:04:12 pm »
As killerbot said... this one is hard to debug.

I just stepped through this code some for some times and I noticed a few things:

1. The adresses that are stored in MenuItemsManager::m_MenuItems are not altered. That means this array is not overwritten and MenuItemsManager::Clear gets the addresses that were added by MenuItemsManager::Insert etc.

2. The values of ni->GetMenu() and ni->GetSubMenu() in MenuItemsManager::Clear seem to be correct and consistant if MenuItemsManager::Clear is called after the configure-dialog for the tools was closed. Therefore no crash here, everything works as expected.

3. If MenuItemsManager::Clear gets called because a plugin was unloaded the value of ni looks still fine but the values of ni->GetMenu() and ni->GetSubMenu() seem to be random values. Therefore we have now undefined behaviour if these pointers are used which often leads to crashes of different types and slightly different places. Now the question ist: Why are the objects pointed to by the elements of MenuItemsManager::m_MenuItems invalid and where did this "invalidation" happen?


Its hard to debug this. Can gdb track some position in memory and interrupt the program if it changes the value at this position? Would be a nice feature here :P
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand.
Real Programmers don't write in BASIC. Actually, no programmers write in BASIC, after the age of 12.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2784
Re: Crash in revision 3412 when disabling plugin
« Reply #5 on: December 27, 2006, 11:29:32 pm »
I want to mention that I had a similar problem with menuItems with keyBinder.
The original keyBinder assumed that menuItems pointers were always static  and valid.

This is not true in CB, or any other app that removes/rewrites/changes the menuItems.  I had to change keyBinder to *always* lookup (verify) the menuItem first. Even the menuItems ID's change in CB. In CB, the menuItem may not be there, or its properties changed in such a way that the menuItem was reallocated.

When CB added bit images to the menu items, I stepped (gdb) into places where the menuItem was deleted/destroyed and reallocated. I had to change keyBinder to match the situation.

I also noticed that a menuItems address can be returned incorrectly even when a Destroy has been called on it, if the call takes place too fast after the destroy.

I don't know if any of the above even applies, just wanted to mention it.
« Last Edit: December 27, 2006, 11:38:39 pm by Pecan »

Online stahta01

  • Lives here!
  • ****
  • Posts: 7594
    • My Best Post
Re: Crash in revision 3412 when disabling plugin
« Reply #6 on: December 30, 2006, 01:27:52 am »
Plugin disable Crash report
 OS Windows XP SP2
 wxW cvs 2.6_BRANCH
 C::B SVN 3440 + Patches
   Patches applied to menuitemsmanager and codecompletion

[ Patch #1774 ] Plugin disable Crash issue partial fix
https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=1774&group_id=5358

Test procedure:

Start with code Completion Plugin OFF
Start with suspected plugins OFF
Suspected Plugins Are:
Code Snippets
Copy Strings to Clipboard
Dev-C++ Devpak Updater
Code Profiler
Source Exporter
1a. disable plugin under test
1b. wait about 2 seconds
1c. enable plugin under test
2. repeat step 1a through 1c
3. repeat step 1a through 1c
4a. enable Completion Plugin 
4b. wait about 2 seconds
4c. disable Completion Plugin 
5. repeat step 4a through 4c
6. repeat step 4a through 4c

Results of tests will be updated in a short time after I re-run them.
The only one to fail on the re-testing using 2 sec time between was
Dev-C++ Devpak Updater

Tim S
« Last Edit: December 30, 2006, 02:21:08 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5498
Re: Crash in revision 3412 when disabling plugin
« Reply #7 on: December 30, 2006, 10:25:55 am »
Quote
[ Patch #1774 ] Plugin disable Crash issue partial fix
https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=1774&group_id=5358
Why do you call it partial ?

Online stahta01

  • Lives here!
  • ****
  • Posts: 7594
    • My Best Post
Re: Crash in revision 3412 when disabling plugin
« Reply #8 on: December 30, 2006, 10:52:59 am »
Quote
[ Patch #1774 ] Plugin disable Crash issue partial fix
https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=1774&group_id=5358
Why do you call it partial ?

Because it still crashes about 10 to 30 % of what it used to.

Also, Dev-C++ Devpak Updater still has major issues.

Tim S
« Last Edit: December 30, 2006, 10:54:59 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org