Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Crash with batch build on linux

<< < (3/10) > >>

BlueHazzard:
By everything you mean also wxWidgets? Because codeblocks is build with -fno-omit-frame-pointer

oBFusCATed:
The whole system would be best, but yes building wx with -fno-omit-frame-pointer improves backtraces produced by asan.

oBFusCATed:
But you don't need asan for tracking this problem just place a breakpoint on ~TextCtrlLogger and you'll find who is deleting it.

BlueHazzard:

--- Code: ---[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()
--- End code ---

This output is somehow more useful then the debugger or not? Anyway, i wanted to learn how to use the address sanitizer and now i have a chance to use it :)

The question now is, why is the window destroyed before the application exits?

Miguel Gimenez:

--- Quote from: BlueHazzard on July 26, 2019, 10:04:48 am ---The question now is, why is the window destroyed before the application exits?

--- End quote ---

Because in batch mode it is not needed anymore. The crash is due to the destruction of the log window before closing the workspace, as there is a call to ClearLog() in the workspace closing event.

Solutions:
  - Use --no-batch-window-close in the command line call
  - Destroy the window after closing the workspace, not before
  - Use my patch in ticket 738
  - Mark the window as destroyed and don't call ClearLog() if it is marked
  - Remove the call to ClearLog() from the workspace closing event

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version