Menu

#1276 Watches dialog causing C::B crash on exit

Undefined
open
nobody
None
Bug_Report
2022-06-15
2022-06-13
No

Bluehazzard found a crash when reviewing the patch for Ticket 654. I have been scratching my head with it and I have found and tested a bunch of different things and looked at other C::B code that uses the clipboard and have been able to reproduce the crash with the following:

C::B version: Nightly svn-r12829
Compiler: Latest MSYS2 Mingw64 & GDB

Steps to reproduce the crash:
1) Start the nightly C::B
2) Load a simple test app with a variable you can watch
3) Set a breakpoint on a line where you can add a watch of some variable
4) Run to the breakpoint
5) Right click on the variable and watch the variable
6) Click on the variable in the watch window
7) Step to the next line (F7)
8) Close the watch window
9) Close C::B windows via [X] on top right & press the [OK] to close project while debugging.
10) Check for rpt file in C:\Users\<username>\AppData\Roaming\CodeBlocks directory if running from program files otherwise the Codeblocks.exe directory</username>

Be aware that different combinations of steps 6 & 7 can cause the crash to not occur. There could be other combinations that also cause the crash to not occur.

Attached is the crash rpt for the nightly and the sample app I use.

I have seen the crash occurs on wxWidgets 3.1.5, 3.1.6 and 3.1.7, but do not have enough wxWidget knowledge to dig into the bug further.

2 Attachments

Related

Tickets: #654

Discussion

  • Andrew Cottrell

    Andrew Cottrell - 2022-06-14

    Attached is the crash report when linked to wx 3.1.7 debug build.

     
  • bluehazzard

    bluehazzard - 2022-06-14

    Can you try this patch and look if it fixes it?

    diff --git a/src/src/debugger_interface_creator.cpp b/src/src/debugger_interface_creator.cpp
    index 537c827eb..625bc68fc 100644
    --- a/src/src/debugger_interface_creator.cpp
    +++ b/src/src/debugger_interface_creator.cpp
    @@ -24,7 +24,7 @@
    
     inline void RemoveDockWindow(wxWindow *window)
     {
    -    if (window)
    +    if (window && !Manager::Get()->IsAppShuttingDown())
         {
             CodeBlocksDockEvent evt(cbEVT_REMOVE_DOCK_WINDOW);
             evt.pWindow = window;
    
     
    • Andrew Cottrell

      Andrew Cottrell - 2022-06-15

      This fixes it.

      How did you figure out this is where the issue is?

       
      • bluehazzard

        bluehazzard - 2022-06-15

        I do not think this fixes the "root" cause of the problem, only a symptom. Your second stack trace was really helpful.

        I think the problem is that on shutdown all windows (in this case also the main frame where the debugger window is) get destroyed and then somehow the sub windows (i am not sure about this mechanism i will try to debug it better). The end result is that the destroyed WatchDlg tries to remove itself from the docking manager and then the docking manager tries to repaint the parent frame what was destroyed previously. With this patch i simply do not remove the watch dialog from the dockmanager when we shutdown codeblocks. It gets destroyed anyway...

        I still would like to remove the root cause of this, or fix the order how windows get destroyed...

         
  • Miguel Gimenez

    Miguel Gimenez - 2022-06-15

    This code at main.cpp:3152 may be related

        #if defined ( __WIN32__ ) || defined ( _WIN64 )
        // For Windows, close shown floating windows before shutdown to avoid hangs in Hide() and
        // crashes in Manager::Shutdown();
        wxAuiPaneInfoArray& all_panes = m_LayoutManager.GetAllPanes();
        for(size_t ii = 0; ii < all_panes.Count(); ++ii)
        {
            wxAuiPaneInfo paneInfo = all_panes[ii];
            if (paneInfo.IsShown() and paneInfo.IsFloating())
                m_LayoutManager.ClosePane(paneInfo);
        }
        #endif
    
     
  • Andrew Cottrell

    Andrew Cottrell - 2022-06-15

    Sorry guys, but this I understand some of it. Some bits I am still learning.

    If you want anything tested or checked or even code multiple code changes and testing or anything you can think of to help please let me know what you want me to do so I can try and help with getting this fixed as I am 1000% confident that I can only help with testing or supplying more info.

     
  • Miguel Gimenez

    Miguel Gimenez - 2022-06-15

    Is the code above compiled at all on your system?

     
    • Andrew Cottrell

      Andrew Cottrell - 2022-06-15

      Yes. I have no local changes between lines 1790 and 4485 of the SVN main.cpp, so the code is compiled in my testing.

       

      Last edit: Andrew Cottrell 2022-06-15
  • Miguel Gimenez

    Miguel Gimenez - 2022-06-15

    I asked if it really compiles; write a syntax error inside the #if

     
    • Andrew Cottrell

      Andrew Cottrell - 2022-06-15

      I added crap "wes2323" inside the #if on new line and the build failed, so yes it compiled with MSYS2 Mingw64 GCC 12.1.0

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.