Author Topic: fatal error on exit  (Read 1972 times)

codex

  • Guest
fatal error on exit
« on: January 06, 2019, 05:09:13 pm »
Sometimes, when I close code::blocks 17.12, a fatal assertion error pop up.
How can I fix this?

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12129
    • Travis build status
Re: fatal error on exit
« Reply #1 on: January 06, 2019, 05:27:12 pm »
You have to try to narrow down the problem.
As a first step it is best if you can make it reproduce every time.

Also when reporting a problem is a good idea to specify the OS you're running. I can see that it is some kind of windows, but I cannot guess it.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

codex

  • Guest
Re: fatal error on exit
« Reply #2 on: January 06, 2019, 05:36:40 pm »
I'm currently running Windows 10 1809 x64, it usually happens when you close it using the taskbar.

EDIT:
Steps to reproduce the error:
1.Open some project
2.Close it with taskbar (right click and choose 'close this window')
It happens every time, I have it installed on another machine and raises same exception.
« Last Edit: January 06, 2019, 05:42:30 pm by codex »

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12129
    • Travis build status
Re: fatal error on exit
« Reply #3 on: January 06, 2019, 05:48:53 pm »
What plugins do you have enabled? Does it happen with a simple console project? Does it happen if you reset all your settings by renaming default.conf file?
Does it happen with a night build (do not use the last two versions, they are known to be buggy)?

Are you prepared to compile cb yourself and try to use a debugger to find out where the problem happens?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

codex

  • Guest
Re: fatal error on exit
« Reply #4 on: January 06, 2019, 05:54:00 pm »
This is a fresh installation of codeblocks-17.12mingw-setup and you can also have no projects open, just tested this.
And I don't know the process of compiling code::blocks myself.

Offline Krice

  • Almost regular
  • **
  • Posts: 130
Re: fatal error on exit
« Reply #5 on: January 07, 2019, 03:00:04 pm »
Why can't you just close it? Why use task manager to end the program? I guess it wont even close proprerly that way, that's why you get the error.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2180
Re: fatal error on exit
« Reply #6 on: January 08, 2019, 05:58:56 pm »
Confirmed.

Windows 10/ CB rev 11540
Code: [Select]
#0 ?? Mgr<EditorManager>::Get () (C:/Usr/Proj/cbBeta/trunk/src/include/manager.h:206)
#1 0x61891b42 Manager::GetEditorManager(this=0x24ace80) (C:\Usr\Proj\cbBeta\trunk\src\sdk\manager.cpp:436)
#2 0x40a27b CodeBlocksApp::OnAppActivate(this=0x24ad848, event=...) (C:\Usr\Proj\cbBeta\trunk\src\src\app.cpp:1450)
#3 0x1cc1262 wxAppConsole::HandleEvent(wxEvtHandler*, void (wxEvtHandler::*)(wxEvent&) (C:\Usr\Proj\wxWidgets2812\lib\gcc_dll\wxmsw28u_gcc_custom.dll:??)
#4 0x14af6dc ?? () (??:??)

Source app.cpp is trying to get the editor manager.
There is a check for shutdown at the beginning of this function, but it obviously has not been set yet.
I don't see any way of knowing that this is entered for shutdown from the taskBar.

The error is caused by the consequences of this line:
        wxPostEvent(Manager::Get()->GetEditorManager(), evt);
which allows OnApplicationClose() to be invoked (thus freeing the Managers) before returning to OnApplicationActivated().

Changing the code to check for shutdown after the post seems to solve the problem:
        wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, idEditorManagerCheckFiles);
        wxPostEvent(Manager::Get()->GetEditorManager(), evt);
        if ( Manager::IsAppShuttingDown())
            return;

Code: [Select]
        // for some reason a mouse up event doesn't make it into scintilla (scintilla bug)
        // therefore the workaround is not to directly call the editorManager, but
        // take a detour through an event
        // the bug is when the file has been offered to reload, no matter what answer you
        // give the mouse is in a selecting mode, adding/removing things to it's selection as you
        // move it around
        // so : idEditorManagerCheckFiles, EditorManager::OnCheckForModifiedFiles just exist for this workaround
        wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, idEditorManagerCheckFiles);
        wxPostEvent(Manager::Get()->GetEditorManager(), evt);
        cbProjectManagerUI *prjManUI = m_Frame->GetProjectManagerUI();
        if (prjManUI)
            static_cast<ProjectManagerUI*>(prjManUI)->CheckForExternallyModifiedProjects();
    }
    cbEditor* ed = Manager::Get()->GetEditorManager()
                 ? Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor() : nullptr;
    if (ed)
    {
        // hack for linux: without it, the editor loses the caret every second activate o.O
        Manager::Get()->GetEditorManager()->GetNotebook()->SetFocus();
        ed->GetControl()->SetFocus();
    }
}

void CodeBlocksApp::AddFileToOpenDelayed(const wxString& filename)

« Last Edit: January 08, 2019, 07:18:34 pm by Pecan »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2180
Re: fatal error on exit
« Reply #7 on: January 31, 2019, 08:30:10 pm »
Fixed: At revision: 11561