Author Topic: Crash with batch build on linux  (Read 425 times)

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2379
Crash with batch build on linux
« on: June 15, 2019, 11:45:05 am »
Hi, i use the command line on my headless server to build codeblocks projects...
I can not reproduce this 100% but it occurs 1 in 6 times: I get a crash "call of pure virtual function" on the finish of a compilation.
This is the backtrace:
Code: [Select]
#0  0x00007ffff41dee97 in raise () at /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007ffff41e0801 in abort () at /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007ffff4bd3957 in  () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff4bd9ab6 in  () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff4bd9af1 in  () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff4bda8bf in  () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007ffff5bf2e29 in wxTextEntryBase::DoSetValue(wxString const&, int) () at /usr/lib/x86_64-linux-gnu/libwx_gtk2u_core-3.0.so.0
#7  0x00007ffff5acd507 in  () at /usr/lib/x86_64-linux-gnu/libwx_gtk2u_core-3.0.so.0
#8  0x00007ffff76b2a2b in TextCtrlLogger::Clear() (this=0x555556356c40) at loggers.cpp:165
#9  0x00007fffe91d91f1 in CompilerGCC::ClearLog(bool) (this=0x555555fcc0f0, switchToLog=false) at compilergcc.cpp:1079
#10 0x00007fffe91e840b in CompilerGCC::OnWorkspaceClosed(CodeBlocksEvent&) (this=0x555555fcc0f0, event=...) at compilergcc.cpp:3437
#11 0x00007fffe91f9411 in cbEventFunctor<CompilerGCC, CodeBlocksEvent>::Call(CodeBlocksEvent&) (this=0x555556533590, event=...) at ../../../src/include/cbfunctor.h:49
#12 0x00007ffff76c3e9a in Manager::ProcessEvent(CodeBlocksEvent&) (this=0x555555b26ba0, event=...) at manager.cpp:263
#13 0x00007ffff76e262b in PluginManager::NotifyPlugins(CodeBlocksEvent&) (this=0x555555f17700, event=...) at pluginmanager.cpp:1522
#14 0x00007ffff770e88f in ProjectManager::CloseWorkspace() (this=0x555555d8f900) at projectmanager.cpp:620
#15 0x00005555556807a7 in MainFrame::DoCloseCurrentWorkspace() (this=0x555555bdb710) at main.cpp:2049
#16 0x0000555555687529 in MainFrame::OnApplicationClose(wxCloseEvent&) (this=0x555555bdb710, event=...) at main.cpp:2929
#17 0x00007ffff52d24be in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () at /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#18 0x00007ffff52d25c3 in wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) () at /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#19 0x00007ffff52d298b in wxEvtHandler::TryHereOnly(wxEvent&) () at /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#20 0x00007ffff52d2783 in wxEvtHandler::DoTryChain(wxEvent&) () at /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#21 0x00007ffff52d2a75 in wxEvtHandler::ProcessEvent(wxEvent&) () at /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#22 0x00007ffff52d27d7 in wxEvtHandler::SafelyProcessEvent(wxEvent&) () at /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#23 0x00007ffff5c039d7 in wxWindowBase::Close(bool) () at /usr/lib/x86_64-linux-gnu/libwx_gtk2u_core-3.0.so.0
#24 0x0000555555605c25 in CodeBlocksApp::OnInit() (this=0x555555a675c0) at app.cpp:759
#25 0x000055555560d5d9 in wxAppConsoleBase::CallOnInit() (this=0x555555a675c0) at /usr/include/wx-3.0/wx/app.h:93
#26 0x00007ffff51e0b3a in wxEntry(int&, wchar_t**) () at /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#27 0x0000555555603bcb in main(int, char**) (argc=5, argv=0x7fffffffe428) at app.cpp:338
Any ideas how to debug this?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11825
    • Travis build status
Re: Crash with batch build on linux
« Reply #1 on: June 15, 2019, 02:20:39 pm »
Run cb from cb and debug it with gdb. Just edit the program arguments and/or work folder.

Most probably the text logger is already deleted when clear is called.
(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!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2379
Re: Crash with batch build on linux
« Reply #2 on: June 16, 2019, 07:03:45 pm »
Wasn't there a ticket or a forum post about the log panel with a fix lately?
I can not find it anymore...

Offline Miguel Gimenez

  • Regular
  • ***
  • Posts: 301
Re: Crash with batch build on linux
« Reply #3 on: June 16, 2019, 07:32:31 pm »
Ticket 738:

https://sourceforge.net/p/codeblocks/tickets/738/

I added a check about batch building before clearing the log, but it wasn't accepted.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11825
    • Travis build status
Re: Crash with batch build on linux
« Reply #4 on: June 16, 2019, 10:21:19 pm »
@Miguel: If you look at the backtrace you'll see that this for the clear call is not nullptr, so your fix would probably be unhelpful in this case.
(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!]

Offline Miguel Gimenez

  • Regular
  • ***
  • Posts: 301
Re: Crash with batch build on linux
« Reply #5 on: June 17, 2019, 11:30:53 am »
While investigating the crash I found this code snippet (not related directly to the crash) in compilergcc.cpp:

Code: [Select]
        if (!Manager::IsBatchBuild())
        {
            CodeBlocksLogEvent evt(cbEVT_REMOVE_LOG_WINDOW, m_pLog);
            Manager::Get()->ProcessEvent(evt);
        }

        {
            // TODO: This is wrong. We need some automatic way for this to happen!!!
            LogSlot &listSlot = logManager->Slot(m_ListPageIndex);
            delete listSlot.icon;
            listSlot.icon = nullptr;

            LogSlot &slot = logManager->Slot(m_PageIndex);
            delete slot.icon;
            slot.icon = nullptr;
        }

        m_pLog = 0;

The log window removal is made conditionally, but the nullifying of m_pLog always happens. Is this correct?