#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
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;
While investigating the crash I found this code snippet (not related directly to the crash) in compilergcc.cpp:So you can reproduce the crash?
==26161==ERROR: AddressSanitizer: heap-use-after-free on address 0x61a000090bc0 at pc 0x7fd9158e6a41 bp 0x7fffba69c060 sp 0x7fffba69c050
READ of size 8 at 0x61a000090bc0 thread T0
#0 0x7fd9158e6a40 in TextCtrlLogger::Clear() (/home/codeblocks/codeblocks/src/output30/libcodeblocks.so+0x8a8a40)
#1 0x7fd90153e22e in CompilerGCC::ClearLog(bool) (/home/codeblocks/codeblocks/src/output30/share/codeblocks/plugins/libcompiler.so+0x10422e)
#2 0x7fd9015649b6 in CompilerGCC::OnWorkspaceClosed(CodeBlocksEvent&) (/home/codeblocks/codeblocks/src/output30/share/codeblocks/plugins/libcompiler.so+0x12a9b6)
#3 0x7fd901588eb3 in cbEventFunctor<CompilerGCC, CodeBlocksEvent>::Call(CodeBlocksEvent&) (/home/codeblocks/codeblocks/src/output30/share/codeblocks/plugins/libcompiler.so+0x14eeb3)
#4 0x7fd9159107f0 in Manager::ProcessEvent(CodeBlocksEvent&) (/home/codeblocks/codeblocks/src/output30/libcodeblocks.so+0x8d27f0)
#5 0x7fd91596ee68 in PluginManager::NotifyPlugins(CodeBlocksEvent&) (/home/codeblocks/codeblocks/src/output30/libcodeblocks.so+0x930e68)
#6 0x7fd9159da356 in ProjectManager::CloseWorkspace() (/home/codeblocks/codeblocks/src/output30/libcodeblocks.so+0x99c356)
#7 0x55778b662f64 (/home/codeblocks/codeblocks/src/output30/codeblocks+0x290f64)
#8 0x55778b67490b (/home/codeblocks/codeblocks/src/output30/codeblocks+0x2a290b)
#9 0x7fd9168674bd in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) (/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0+0x1e34bd)
#10 0x7fd9168675c2 in wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) (/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0+0x1e35c2)
#11 0x7fd91686798a in wxEvtHandler::TryHereOnly(wxEvent&) (/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0+0x1e398a)
#12 0x7fd916867782 in wxEvtHandler::DoTryChain(wxEvent&) (/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0+0x1e3782)
#13 0x7fd916867a74 in wxEvtHandler::ProcessEvent(wxEvent&) (/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0+0x1e3a74)
#14 0x7fd9168677d6 in wxEvtHandler::SafelyProcessEvent(wxEvent&) (/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0+0x1e37d6)
#15 0x7fd9171989d6 in wxWindowBase::Close(bool) (/usr/lib/x86_64-linux-gnu/libwx_gtk2u_core-3.0.so.0+0x4419d6)
#16 0x55778b52e391 (/home/codeblocks/codeblocks/src/output30/codeblocks+0x15c391)
#17 0x55778b54085b (/home/codeblocks/codeblocks/src/output30/codeblocks+0x16e85b)
#18 0x7fd916775b39 in wxEntry(int&, wchar_t**) (/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0+0xf1b39)
#19 0x55778b528e66 (/home/codeblocks/codeblocks/src/output30/codeblocks+0x156e66)
#20 0x7fd914110b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
#21 0x55778b526dd9 (/home/codeblocks/codeblocks/src/output30/codeblocks+0x154dd9)
0x61a000090bc0 is located 1344 bytes inside of 1408-byte region [0x61a000090680,0x61a000090c00)
freed by thread T0 here:
#0 0x7fd9187b22d0 in operator delete(void*) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe12d0)
#1 0x7fd917197316 in wxWindowBase::Destroy() (/usr/lib/x86_64-linux-gnu/libwx_gtk2u_core-3.0.so.0+0x440316)
previously allocated by thread T0 here:
#0 0x7fd9187b1458 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0458)
#1 0x7fd9158e6be1 in TextCtrlLogger::CreateControl(wxWindow*) (/home/codeblocks/codeblocks/src/output30/libcodeblocks.so+0x8a8be1)
#2 0x7fd90157e7e9 in BuildLogger::CreateControl(wxWindow*) (/home/codeblocks/codeblocks/src/output30/share/codeblocks/plugins/libcompiler.so+0x1447e9)
#3 0x55778b68c058 (/home/codeblocks/codeblocks/src/output30/codeblocks+0x2ba058)
#4 0x55778b6beea3 (/home/codeblocks/codeblocks/src/output30/codeblocks+0x2ecea3)
#5 0x7fd915911534 in Manager::ProcessEvent(CodeBlocksLogEvent&) (/home/codeblocks/codeblocks/src/output30/libcodeblocks.so+0x8d3534)
#6 0x7fd901530e5c in CompilerGCC::OnAttach() (/home/codeblocks/codeblocks/src/output30/share/codeblocks/plugins/libcompiler.so+0xf6e5c)
#7 0x7fd9156bf8ab in cbPlugin::Attach() (/home/codeblocks/codeblocks/src/output30/libcodeblocks.so+0x6818ab)
#8 0x7fd915958536 in PluginManager::AttachPlugin(cbPlugin*, bool) (/home/codeblocks/codeblocks/src/output30/libcodeblocks.so+0x91a536)
#9 0x7fd91596a2db in PluginManager::LoadAllPlugins() (/home/codeblocks/codeblocks/src/output30/libcodeblocks.so+0x92c2db)
#10 0x55778b652241 (/home/codeblocks/codeblocks/src/output30/codeblocks+0x280241)
#11 0x55778b6417bb (/home/codeblocks/codeblocks/src/output30/codeblocks+0x26f7bb)
#12 0x55778b529d6c (/home/codeblocks/codeblocks/src/output30/codeblocks+0x157d6c)
#13 0x55778b52dcc1 (/home/codeblocks/codeblocks/src/output30/codeblocks+0x15bcc1)
#14 0x55778b54085b (/home/codeblocks/codeblocks/src/output30/codeblocks+0x16e85b)
#15 0x7fd916775b39 in wxEntry(int&, wchar_t**) (/usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0+0xf1b39)
SUMMARY: AddressSanitizer: heap-use-after-free (/home/codeblocks/codeblocks/src/output30/libcodeblocks.so+0x8a8a40) in TextCtrlLogger::Clear()
Shadow bytes around the buggy address:
0x0c348000a120: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0c348000a130: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0c348000a140: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0c348000a150: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0c348000a160: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
=>0x0c348000a170: fd fd fd fd fd fd fd fd[fd]fd fd fd fd fd fd fd
0x0c348000a180: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c348000a190: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c348000a1a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c348000a1b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c348000a1c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==26161==ABORTING
output30/run.sh --target=All --no-splash-screen --build CodeBlocks_wx30-unix.workspace
[debug]=================================================================
[debug]==16639==ERROR: AddressSanitizer: heap-use-after-free on address 0x61a0000809c0 at pc 0x7ffff4c90861 bp 0x7fffffffba00 sp 0x7fffffffb9f0
[debug]READ of size 8 at 0x61a0000809c0 thread T0
[debug] #0 0x7ffff4c90860 in TextCtrlLogger::Clear() /home/codeblocks/codeblocks/src/sdk/loggers.cpp:165
[debug] #1 0x7fffe217813e in CompilerGCC::ClearLog(bool) /home/codeblocks/codeblocks/src/plugins/compilergcc/compilergcc.cpp:1108
[debug] #2 0x7fffe219e8c6 in CompilerGCC::OnWorkspaceClosed(CodeBlocksEvent&) /home/codeblocks/codeblocks/src/plugins/compilergcc/compilergcc.cpp:3466
[debug] #3 0x7fffe21c2dc3 in cbEventFunctor<CompilerGCC, CodeBlocksEvent>::Call(CodeBlocksEvent&) /home/codeblocks/codeblocks/src/include/cbfunctor.h:49
[debug] #4 0x7ffff4cba610 in Manager::ProcessEvent(CodeBlocksEvent&) /home/codeblocks/codeblocks/src/sdk/manager.cpp:269
[debug] #5 0x7ffff4d18c88 in PluginManager::NotifyPlugins(CodeBlocksEvent&) /home/codeblocks/codeblocks/src/sdk/pluginmanager.cpp:1522
[debug] #6 0x7ffff4d84176 in ProjectManager::CloseWorkspace() /home/codeblocks/codeblocks/src/sdk/projectmanager.cpp:620
[debug] #7 0x5555557e4d94 in MainFrame::DoCloseCurrentWorkspace() /home/codeblocks/codeblocks/src/src/main.cpp:2136
[debug] #8 0x5555557f673b in MainFrame::OnApplicationClose(wxCloseEvent&) /home/codeblocks/codeblocks/src/src/main.cpp:3015
[debug] #9 0x7ffff602e4e1 in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0x5fb4e1)
[debug] #10 0x7ffff602e5ea in wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0x5fb5ea)
[debug] #11 0x7ffff602e9f6 in wxEvtHandler::TryHereOnly(wxEvent&) (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0x5fb9f6)
[debug] #12 0x7ffff602e7e5 in wxEvtHandler::DoTryChain(wxEvent&) (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0x5fb7e5)
[debug] #13 0x7ffff602ead5 in wxEvtHandler::ProcessEvent(wxEvent&) (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0x5fbad5)
[debug] #14 0x7ffff602e83e in wxEvtHandler::SafelyProcessEvent(wxEvent&) (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0x5fb83e)
[debug] #15 0x7ffff6275777 in wxWindowBase::Close(bool) (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0x842777)
[debug] #16 0x5555556b01c1 in CodeBlocksApp::OnInit() /home/codeblocks/codeblocks/src/src/app.cpp:753
[debug] #17 0x5555556c268b in wxAppConsoleBase::CallOnInit() (/home/codeblocks/codeblocks/src/devel30/codeblocks+0x16e68b)
[debug] #18 0x7ffff5f3efa1 in wxEntry(int&, wchar_t**) (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0x50bfa1)
[debug] #19 0x5555556aac96 in main /home/codeblocks/codeblocks/src/src/app.cpp:338
[debug] #20 0x7ffff34bab96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
[debug] #21 0x5555556a8c09 in _start (/home/codeblocks/codeblocks/src/devel30/codeblocks+0x154c09)
[debug]0x61a0000809c0 is located 1344 bytes inside of 1408-byte region [0x61a000080480,0x61a000080a00)
[debug]freed by thread T0 here:
[debug] #0 0x7ffff6efb9d8 in operator delete(void*, unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe19d8)
[debug] #1 0x7ffff6273fbe in wxWindowBase::Destroy() (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0x840fbe)
[debug] #2 0x7ffff627400b in wxWindowBase::DestroyChildren() (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0x84100b)
[debug] #3 0x7ffff60afbab in wxWindow::~wxWindow() (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0x67cbab)
[debug] #4 0x7ffff622e3ca in wxPanel::~wxPanel() (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0x7fb3ca)
[debug] #5 0x7ffff6273fbe in wxWindowBase::Destroy() (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0x840fbe)
[debug] #6 0x7ffff64ac83c in wxAuiNotebook::DeletePage(unsigned long) (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0xa7983c)
[debug] #7 0x7ffff64b3739 in wxAuiNotebook::~wxAuiNotebook() (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0xa80739)
[debug] #8 0x7ffff4a0956e in cbAuiNotebook::~cbAuiNotebook() /home/codeblocks/codeblocks/src/sdk/cbauibook.cpp:80
[debug] #9 0x5555557b8993 in InfoPane::~InfoPane() /home/codeblocks/codeblocks/src/src/infopane.cpp:65
[debug] #10 0x5555557b89bf in InfoPane::~InfoPane() /home/codeblocks/codeblocks/src/src/infopane.cpp:72
[debug] #11 0x7ffff6273fbe in wxWindowBase::Destroy() (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0x840fbe)
[debug] #12 0x7ffff627400b in wxWindowBase::DestroyChildren() (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0x84100b)
[debug] #13 0x7ffff60afbab in wxWindow::~wxWindow() (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0x67cbab)
[debug] #14 0x5555556f986e in wxScrollingDialog::~wxScrollingDialog() /home/codeblocks/codeblocks/src/include/scrollingdialog.h:163
[debug] #15 0x555555840724 in BatchLogWindow::~BatchLogWindow() /home/codeblocks/codeblocks/src/src/batchbuild.h:15
[debug] #16 0x55555584073f in BatchLogWindow::~BatchLogWindow() /home/codeblocks/codeblocks/src/src/batchbuild.h:15
[debug] #17 0x7ffff5eb01fa in wxAppConsoleBase::DeletePendingObjects() (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0x47d1fa)
[debug] #18 0x7ffff5eb0273 in wxAppConsoleBase::ProcessIdle() (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0x47d273)
[debug] #19 0x7ffff614ccdb in wxAppBase::ProcessIdle() (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0x719cdb)
[debug] #20 0x7ffff6072a98 in wxApp::DoIdle() (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0x63fa98)
[debug] #21 0x7ffff6072ba2 in wxapp_idle_callback (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0x63fba2)
[debug] #22 0x7ffff148d284 in g_main_context_dispatch (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x4c284)
[debug]previously allocated by thread T0 here:
[debug] #0 0x7ffff6efa458 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0458)
[debug] #1 0x7ffff4c90a01 in TextCtrlLogger::CreateControl(wxWindow*) /home/codeblocks/codeblocks/src/sdk/loggers.cpp:171
[debug] #2 0x7fffe21b86f9 in BuildLogger::CreateControl(wxWindow*) (/home/codeblocks/codeblocks/src/devel30/share/codeblocks/plugins/libcompiler.so+0x1446f9)
[debug] #3 0x55555580de88 in MainFrame::OnAddLogWindow(CodeBlocksLogEvent&) /home/codeblocks/codeblocks/src/src/main.cpp:5146
[debug] #4 0x555555840cd3 in cbEventFunctor<MainFrame, CodeBlocksLogEvent>::Call(CodeBlocksLogEvent&) /home/codeblocks/codeblocks/src/include/cbfunctor.h:49
[debug] #5 0x7ffff4cbb354 in Manager::ProcessEvent(CodeBlocksLogEvent&) /home/codeblocks/codeblocks/src/sdk/manager.cpp:337
[debug] #6 0x7fffe216ad6c in CompilerGCC::OnAttach() /home/codeblocks/codeblocks/src/plugins/compilergcc/compilergcc.cpp:414
[debug] #7 0x7ffff4a696cb in cbPlugin::Attach() /home/codeblocks/codeblocks/src/sdk/cbplugin.cpp:73
[debug] #8 0x7ffff4d02356 in PluginManager::AttachPlugin(cbPlugin*, bool) /home/codeblocks/codeblocks/src/sdk/pluginmanager.cpp:197
[debug] #9 0x7ffff4d140fb in PluginManager::LoadAllPlugins() /home/codeblocks/codeblocks/src/sdk/pluginmanager.cpp:1108
[debug] #10 0x5555557d4071 in MainFrame::ScanForPlugins() /home/codeblocks/codeblocks/src/src/main.cpp:1299
[debug] #11 0x5555557c35eb in MainFrame::MainFrame(wxWindow*) /home/codeblocks/codeblocks/src/src/main.cpp:633
[debug] #12 0x5555556abb9c in CodeBlocksApp::InitFrame() /home/codeblocks/codeblocks/src/src/app.cpp:505
[debug] #13 0x5555556afaf1 in CodeBlocksApp::OnInit() /home/codeblocks/codeblocks/src/src/app.cpp:720
[debug] #14 0x5555556c268b in wxAppConsoleBase::CallOnInit() (/home/codeblocks/codeblocks/src/devel30/codeblocks+0x16e68b)
[debug] #15 0x7ffff5f3efa1 in wxEntry(int&, wchar_t**) (/home/codeblocks/wxInstall30/lib/libwx_gtk2u-3.0.so.0+0x50bfa1)
[debug] #16 0x5555556aac96 in main /home/codeblocks/codeblocks/src/src/app.cpp:338
[debug] #17 0x7ffff34bab96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
[debug]SUMMARY: AddressSanitizer: heap-use-after-free /home/codeblocks/codeblocks/src/sdk/loggers.cpp:165 in TextCtrlLogger::Clear()
The question now is, why is the window destroyed before the application exits?
Destroy the window after closing the workspace, not beforeThis is somehow the solution i would like look into... Maybe i find some time...
The window is destroyed in the CodeBlocksApp::OnInit method and this needs to change.Obviously this is the only correct fix. I doubt wx is really happy when we destroy windows from OnInit.
diff --git a/src/src/app.cpp b/src/src/app.cpp
index 22a46dfb1..abb415c60 100644
--- a/src/src/app.cpp
+++ b/src/src/app.cpp
@@ -974,6 +974,7 @@ int CodeBlocksApp::BatchJob()
wxString bb_title = m_pBatchBuildDialog->GetTitle();
m_pBatchBuildDialog->SetTitle(bb_title + _T(" - ") + title);
m_pBatchBuildDialog->Show();
+ m_pBatchBuildDialog->Bind(wxEVT_CLOSE_WINDOW, [=](wxCloseEvent& evt) { m_Frame->Close();});
if (m_ReBuild)
{
@@ -1000,7 +1001,7 @@ int CodeBlocksApp::BatchJob()
// The batch build log might have been deleted in
// CodeBlocksApp::OnBatchBuildDone().
// If it has not, it's still compiling.
- if (m_pBatchBuildDialog)
+ /*if (m_pBatchBuildDialog)
{
// If operation is "--clean", there is no need to display the dialog
// as the operation is synchronous and it already has finished by the
@@ -1015,7 +1016,7 @@ int CodeBlocksApp::BatchJob()
m_pBatchBuildDialog->Destroy();
m_pBatchBuildDialog = nullptr;
}
- }
+ }*/
if (tbIcon)
{
diff --git a/src/src/app.cpp b/src/src/app.cpp
index 22a46dfb1..8b90cae68 100644
--- a/src/src/app.cpp
+++ b/src/src/app.cpp
@@ -749,8 +749,15 @@ bool CodeBlocksApp::OnInit()
s_Loading = false;
LoadDelayedFiles(frame);
- BatchJob();
- frame->Close();
+ m_startBatchBuild.Bind(wxEVT_TIMER, [this](wxTimerEvent& evt)
+ {
+ this->BatchJob();
+ });
+
+ m_startBatchBuild.Start(2000, true);
+
+
+ //frame->Close();
return true;
}
@@ -974,6 +981,10 @@ int CodeBlocksApp::BatchJob()
wxString bb_title = m_pBatchBuildDialog->GetTitle();
m_pBatchBuildDialog->SetTitle(bb_title + _T(" - ") + title);
m_pBatchBuildDialog->Show();
+ m_pBatchBuildDialog->Bind(wxEVT_CLOSE_WINDOW, [=](wxCloseEvent& evt)
+ {
+ m_Frame->Close();
+ });
if (m_ReBuild)
{
@@ -1000,7 +1011,7 @@ int CodeBlocksApp::BatchJob()
// The batch build log might have been deleted in
diff --git a/src/src/app.cpp b/src/src/app.cpp
index 22a46dfb1..8b90cae68 100644
--- a/src/src/app.cpp
+++ b/src/src/app.cpp
@@ -749,8 +749,15 @@ bool CodeBlocksApp::OnInit()
s_Loading = false;
LoadDelayedFiles(frame);
- BatchJob();
- frame->Close();
+ m_startBatchBuild.Bind(wxEVT_TIMER, [this](wxTimerEvent& evt)
+ {
+ this->BatchJob();
+ });
+
+ m_startBatchBuild.Start(2000, true);
+
+
+ //frame->Close();
return true;
}
@@ -974,6 +981,10 @@ int CodeBlocksApp::BatchJob()
wxString bb_title = m_pBatchBuildDialog->GetTitle();
m_pBatchBuildDialog->SetTitle(bb_title + _T(" - ") + title);
m_pBatchBuildDialog->Show();
+ m_pBatchBuildDialog->Bind(wxEVT_CLOSE_WINDOW, [=](wxCloseEvent& evt)
+ {
+ m_Frame->Close();
+ });
if (m_ReBuild)
{
@@ -1000,7 +1011,7 @@ int CodeBlocksApp::BatchJob()
// The batch build log might have been deleted in
diff --git a/src/src/app.cpp b/src/src/app.cpp
index 22a46dfb1..8b90cae68 100644
--- a/src/src/app.cpp
+++ b/src/src/app.cpp
@@ -749,8 +749,15 @@ bool CodeBlocksApp::OnInit()
s_Loading = false;
LoadDelayedFiles(frame);
- BatchJob();
- frame->Close();
+ m_startBatchBuild.Bind(wxEVT_TIMER, [this](wxTimerEvent& evt)
+ {
+ this->BatchJob();
+ });
+
+ m_startBatchBuild.Start(2000, true);
+
+
+ //frame->Close();
return true;
}
@@ -974,6 +981,10 @@ int CodeBlocksApp::BatchJob()
wxString bb_title = m_pBatchBuildDialog->GetTitle();
m_pBatchBuildDialog->SetTitle(bb_title + _T(" - ") + title);
m_pBatchBuildDialog->Show();
+ m_pBatchBuildDialog->Bind(wxEVT_CLOSE_WINDOW, [=](wxCloseEvent& evt)
+ {
+ m_Frame->Close();
+ });
if (m_ReBuild)
{
@@ -1000,7 +1011,7 @@ int CodeBlocksApp::BatchJob()
// The batch build log might have been deleted in
// CodeBlocksApp::OnBatchBuildDone().
// If it has not, it's still compiling.
- if (m_pBatchBuildDialog)
+ /*if (m_pBatchBuildDialog)
{
// If operation is "--clean", there is no need to display the dialog
// as the operation is synchronous and it already has finished by the
@@ -1015,7 +1026,7 @@ int CodeBlocksApp::BatchJob()
m_pBatchBuildDialog->Destroy();
m_pBatchBuildDialog = nullptr;
}
- }
+ }*/
if (tbIcon)
{
@@ -1053,13 +1064,16 @@ void CodeBlocksApp::OnBatchBuildDone(CodeBlocksEvent& event)
if (m_pBatchBuildDialog && m_BatchWindowAutoClose)
{
- if (m_pBatchBuildDialog->IsModal())
+ /*if (m_pBatchBuildDialog->IsModal())
m_pBatchBuildDialog->EndModal(wxID_OK);
else
{
- m_pBatchBuildDialog->Destroy();
- m_pBatchBuildDialog = nullptr;
- }
+
+
+ }*/
+ m_pBatchBuildDialog->Close();
+ //m_pBatchBuildDialog->Destroy();
+ //m_pBatchBuildDialog = nullptr;
}
}
diff --git a/src/src/app.h b/src/src/app.h
index 97c69e74e..953916fba 100644
--- a/src/src/app.h
+++ b/src/src/app.h
@@ -142,6 +142,8 @@ class CodeBlocksApp : public wxApp
void SetupPersonality(const wxString& personality);
void SetupImageSizes(wxToolBarAddOnXmlHandler *toolbarAddonHandler);
+ wxTimer m_startBatchBuild;
+
wxString m_Prefix; // directory specified in --prefix switch
wxString m_UserDataDir; // directory specified in --user-data-dir switch
1) Is there some way to know when the build is completely finished? Not just project or file, but workspace? (If not, why do we do not have an event for this?)Not my business 8)
2) Is there a way to wait until the event queue is completely empty?Sort of, wxWidgets will create an Idle-Event whenever the main event loop runs empty, however that doesn't mean that there won't be any new events beeing queued. Only way to know that wxWidgets is about to end is when the OnExit() method of the App object is called. This however requires that wxWidgets will be stopped which usually does not happen if there is a wxFrame open.
3) Is there a way to put an event at the end of the event loop?You can use QueueEvent() or CallAfter() but this will queue the event at the end of the wxEvtHandler you called these methods on, there may be other event handlers active that will be called later, hence these events are only locally at the end, not globally. Plus i am not sure which of these do work in wx 2.8.
diff --git a/src/src/app.cpp b/src/src/app.cpp
index 22a46dfb1..5263e1d2c 100644
--- a/src/src/app.cpp
+++ b/src/src/app.cpp
@@ -749,8 +749,15 @@ bool CodeBlocksApp::OnInit()
s_Loading = false;
LoadDelayedFiles(frame);
- BatchJob();
- frame->Close();
+ m_startBatchBuild.Bind(wxEVT_TIMER, [this](wxTimerEvent& evt)
+ {
+ this->BatchJob();
+ });
+
+ m_startBatchBuild.Start(2000, true);
+
+
+ //frame->Close();
return true;
}
@@ -974,6 +981,21 @@ int CodeBlocksApp::BatchJob()
wxString bb_title = m_pBatchBuildDialog->GetTitle();
m_pBatchBuildDialog->SetTitle(bb_title + _T(" - ") + title);
m_pBatchBuildDialog->Show();
+ m_pBatchBuildDialog->Bind(wxEVT_CLOSE_WINDOW, [=](wxCloseEvent& evt)
+ {
+ //m_sceduleForClose = true;
+ cbCompilerPlugin *compiler = Manager::Get()->GetPluginManager()->GetFirstCompiler();
+ if(compiler != nullptr && compiler->IsRunning())
+ {
+ evt.Veto();
+ compiler->KillProcess();
+ }
+ else
+ {
+ m_Frame->Close();
+ }
+
+ });
if (m_ReBuild)
{
@@ -1000,7 +1022,7 @@ int CodeBlocksApp::BatchJob()
// The batch build log might have been deleted in
// CodeBlocksApp::OnBatchBuildDone().
// If it has not, it's still compiling.
- if (m_pBatchBuildDialog)
+ /*if (m_pBatchBuildDialog)
{
// If operation is "--clean", there is no need to display the dialog
// as the operation is synchronous and it already has finished by the
@@ -1015,7 +1037,7 @@ int CodeBlocksApp::BatchJob()
m_pBatchBuildDialog->Destroy();
m_pBatchBuildDialog = nullptr;
}
- }
+ }*/
if (tbIcon)
{
@@ -1053,13 +1075,23 @@ void CodeBlocksApp::OnBatchBuildDone(CodeBlocksEvent& event)
if (m_pBatchBuildDialog && m_BatchWindowAutoClose)
{
- if (m_pBatchBuildDialog->IsModal())
+ /*if (m_pBatchBuildDialog->IsModal())
m_pBatchBuildDialog->EndModal(wxID_OK);
else
{
- m_pBatchBuildDialog->Destroy();
- m_pBatchBuildDialog = nullptr;
- }
+
+
+ }*/
+ //m_Frame->Close();
+ m_closeCodeblocks.Bind(wxEVT_TIMER, [=](wxTimerEvent& evt)
+ {
+ m_pBatchBuildDialog->Close();
+ });
+ m_closeCodeblocks.Start(3000, true);
+
+ //m_pBatchBuildDialog->Close();
+ //m_pBatchBuildDialog->Destroy();
+ //m_pBatchBuildDialog = nullptr;
}
}
diff --git a/src/src/app.h b/src/src/app.h
index 97c69e74e..4aafa9f7e 100644
--- a/src/src/app.h
+++ b/src/src/app.h
@@ -142,6 +142,9 @@ class CodeBlocksApp : public wxApp
void SetupPersonality(const wxString& personality);
void SetupImageSizes(wxToolBarAddOnXmlHandler *toolbarAddonHandler);
+ wxTimer m_startBatchBuild;
+ wxTimer m_closeCodeblocks;
+
wxString m_Prefix; // directory specified in --prefix switch
wxString m_UserDataDir; // directory specified in --user-data-dir switch
if (m_Batch)
{
Manager::SetAppStartedUp(true);
// the compiler plugin might be waiting for this
CodeBlocksEvent event(cbEVT_APP_STARTUP_DONE);
Manager::Get()->ProcessEvent(event);
Manager::Get()->RegisterEventSink(cbEVT_COMPILER_FINISHED, new cbEventFunctor<CodeBlocksApp, CodeBlocksEvent>(this, &CodeBlocksApp::OnBatchBuildDone));
s_Loading = false;
LoadDelayedFiles(frame);
BatchJob();
frame->Close();
return true;
}
if (m_Batch)
{
CallAfter([this, frame]() {
Manager::SetAppStartedUp(true);
// the compiler plugin might be waiting for this
CodeBlocksEvent event(cbEVT_APP_STARTUP_DONE);
Manager::Get()->ProcessEvent(event);
Manager::Get()->RegisterEventSink(cbEVT_COMPILER_FINISHED, new cbEventFunctor<CodeBlocksApp, CodeBlocksEvent>(this, &CodeBlocksApp::OnBatchBuildDone));
s_Loading = false;
LoadDelayedFiles(frame);
BatchJob();
frame->Close();
});
return true;
}
I examined the code only a little but i spot one big problem there: you are doing operations that create / use events in OnInit(). There is no event loop running in OnInit(). You get around it partly by processing events manually but still this looks like trouble, especially because the event handlers will get executed before OnInit() did finish. Offloading the work with timers actually postones the execution of the code because these will get executed later by the event loop.So what would be the wxWidgets way to do this?
@oBFusCATed: I don't think idle events are the way to go, they happen all the time and are not suited for one time tasks. These lambdas are nice to write code in one place and let it execute in another place, like work units for a work queue. But i also like auto so im afraid we won't agree here as well ::) ;DI know people like to run their whole applications from inside a lamdba, but this doesn't make it a good idea. Same as the almost-always-auto crap. I've seen it in the wild and it is not fun when something breaks. 8)
CallAfter([=]() {
});
CallAfter([=]()
{
});
I don't think what you're doing is a good ideaWhy not? The problem is we start the build process in the OnInit() method, and stop it in a codeblocks event method. In both cases the Output windows is destroyed before all window work is done.
You patch has zero comments explaining why you have to use these CallAfters. This is really unacceptable!
diff --git a/src/src/app.cpp b/src/src/app.cpp
index 22a46dfb1..b6cc11fd3 100644
--- a/src/src/app.cpp
+++ b/src/src/app.cpp
@@ -749,8 +749,12 @@ bool CodeBlocksApp::OnInit()
s_Loading = false;
LoadDelayedFiles(frame);
- BatchJob();
- frame->Close();
+ // Start the batch build after finishing the init process
+ CallAfter([this]()
+ {
+ this->BatchJob();
+ });
+
return true;
}
I'm talking strictly about formatting here.QuoteI don't think what you're doing is a good ideaWhy not?
// Start the batch build after finishing the init processSorry, but this is useless comment. It is the same as commenting that you are setting a variable to some value. Good comments answer the why question and not the what question. (sometimes there is a need for a comment answering the what question, but this is not one of them).
Why have you changed the process stuff?Because i have an automated build system for linux and windows that builds itself and then builds codeblocks automatically. I can not test one patch without the other, because if the process stuff is missing, the build will stall on windows, and if the CallAfter part is missing the build will crash on linux.
For now it is best to make this only compile if building against wx3.x.
Why are you showing a message box in OnCloseBatchBuildWindow? It should be possible to run batch build on a headless machine where there is no operator. For example running in on appvoyer.We had this discussion on top (or at SF):
Is this patch ok for you?Fine...
Here is the windows part. Thank you for showing me the error of the flags. I tried also to add some documentation and why we use this timer function...Does this polling work fine on linux? Does it add overhead? I don't like default values for parameters.