Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: ollydbg on October 17, 2022, 04:50:27 am

Title: bug report: C::B crash when I remove the target from a cbp
Post by: ollydbg on October 17, 2022, 04:50:27 am
Steps to reproduce this crash:

1, open a cbp project which has some targets
2, open the cbp property dialog, and delete some targets.
3, press the OK button of the dialog
4, C::B crash

I'm using the latest rev 12977

The crash call-stack looks like below:
Code
codeblocks.exe caused an Access Violation at location 000007FEE82F9B4C in module libstdc++-6.dll Reading from location 00000000000009C6.

AddrPC           Params
000007FEE82F9B4C 0000000000000001 0000000000000026 00000000030DC910  libstdc++-6.dll!std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::basic_string+0xc
000007FEE5DFEA00 00000000002F6780 00000000000009BE 00000000002F6A60  codeblocks.dll!ConfigManager::GetUserDataFolder+0x6cc20
000007FEE5E29603 00000000002F6A30 00000000000009BE 0000000006D7DEE0  codeblocks.dll!cbThreadPool::Done+0xb043
000007FEE5B6B5B5 00000000065DE420 0000000006FE7260 0000000000000000  codeblocks.dll!MacrosManager::RecalcVars+0x107
000007FEE5B70134 00000000065DE420 00000000002F97C0 0000000006F0DE80  codeblocks.dll!MacrosManager::ReplaceMacros+0x420
000007FEE5B94FAA 0000000006D41F30 0000000006F0DE80 0000000006FE0560  codeblocks.dll!ProjectFile::CompareProjectFiles+0x45e
000007FEE5B94875 0000000006FE0560 0000000006F0DE80 00000000002FAC30  codeblocks.dll!ProjectFile::DoUpdateFileDetails+0xb5
000007FEE5B94795 0000000006FE0560 0000000000000000 0000000006FE7200  codeblocks.dll!ProjectFile::UpdateFileDetails+0xcf
000000013F150495 0000000006FE7260 0000000006FE7458 0000000000000050  codeblocks.exe!0xb0495
000000013F14566C 00000000028A7DC0 00000000002FB750 0000000000490F40  codeblocks.exe!0xa566c
000007FEE6122E77 00000000033EFFE0 0000000000000000 0000000000000000  wxmsw32u_gcc_cb.dll!wxAppConsoleBase::CallEventHandler+0xb7
000007FEE6272AA5 00000000032A9830 0000000000000000 0000000000000084  wxmsw32u_gcc_cb.dll!wxEvtHandler::ProcessEventIfMatchesId+0x85
000007FEE6272C8B 00000000028A7DC0 00000000002FB570 0000000000000000  wxmsw32u_gcc_cb.dll!wxEventHashTable::HandleEvent+0xfb
000007FEE62732CD 0000000000000111 0000000000000000 0000000000141598  wxmsw32u_gcc_cb.dll!wxEvtHandler::TryHereOnly+0x3d
000007FEE6272D73 0000000002369820 00000000002FB750 0000000000000000  wxmsw32u_gcc_cb.dll!wxEvtHandler::DoTryChain+0x43
000007FEE6273421 000000000308F3B0 00000000002FB750 00000000FFFFFFFF  wxmsw32u_gcc_cb.dll!wxEvtHandler::ProcessEvent+0xc1
000007FEE65957C8 000000000308F3B0 000007FEE6274EDB 0000000000000001  wxmsw32u_gcc_cb.dll!wxWindowBase::TryAfter+0x58
000007FEE65957C8 000007FEE6FADB80 00000000002FBEE0 00000000002FB750  wxmsw32u_gcc_cb.dll!wxWindowBase::TryAfter+0x58
000007FEE6274EDB 000000000308F3B0 000007FEE645C1E9 00000000002FBA08  wxmsw32u_gcc_cb.dll!wxEvtHandler::SafelyProcessEvent+0xb
000007FEE653C8AA 0000000000000070 FFFFFFFFFFFFFFFF FFFFFFFFFFFF0000  wxmsw32u_gcc_cb.dll!wxMenuBase::SendEvent+0xca
000007FEE63FFF9D 000000000014148A 000007FEFACE22F8 0000000000000084  wxmsw32u_gcc_cb.dll!wxMenu::MSWCommand+0x9d
000007FEE637A64B 0000000000000111 000007FFFFFDD000 0000000000000000  wxmsw32u_gcc_cb.dll!wxWindow::MSWHandleMessage+0x12cb
000007FEE6365EFC 0000000000000000 0000000000000038 00000000002FBBF8  wxmsw32u_gcc_cb.dll!wxWindow::MSWWindowProc+0x2c
0000000077609861 00000000002FBCE0 000007FEE636E420 00000000776095C0  USER32.dll!TranslateMessageEx+0x291
0000000077609572 00000000002FBCE0 00000000002FBCE0 000007FEE636E420  USER32.dll!TranslateMessage+0x1de
000007FEE6367E71 00000000004BE230 00000000002FE910 000000000308F3B0  wxmsw32u_gcc_cb.dll!wxWindow::DoPopupMenu+0xa1
000007FEE6590FC4 00000000002FBF98 00000000004BE230 000007FEE6DB6594  wxmsw32u_gcc_cb.dll!wxWindowBase::PopupMenu+0x44
000000013F19989C 000000000308F3B0 00000000002FBEE0 00000000002FE4F8  codeblocks.exe!0xf989c
000000013F13CC6B 00000000028A7DC0 00000000003E5CE0 00000000002FE4F8  codeblocks.exe!0x9cc6b
000000013F140DBB 00000000028A7DC0 00000000002FE910 0000000002050001  codeblocks.exe!0xa0dbb
000007FEE6122E77 0000000000141598 000000000000113E 0000000000000000  wxmsw32u_gcc_cb.dll!wxAppConsoleBase::CallEventHandler+0xb7
000007FEE6272AA5 0000000000001111 0000000000000000 00000000002FE890  wxmsw32u_gcc_cb.dll!wxEvtHandler::ProcessEventIfMatchesId+0x85
000007FEE6272C8B 00000000028A7DC0 0000000000001111 0000000000001111  wxmsw32u_gcc_cb.dll!wxEventHashTable::HandleEvent+0xfb
000007FEE62732CD 0000000000002803 0000000000002859 00000000000907DA  wxmsw32u_gcc_cb.dll!wxEvtHandler::TryHereOnly+0x3d
000007FEE6272D73 0000000002369820 00000000002FE910 0000000000000000  wxmsw32u_gcc_cb.dll!wxEvtHandler::DoTryChain+0x43
000007FEE6273421 000000000308F3B0 00000000002FE910 00000000002FE910  wxmsw32u_gcc_cb.dll!wxEvtHandler::ProcessEvent+0xc1
000007FEE65957C8 0000000000000014 00000000003E5CE0 0000000000000072  wxmsw32u_gcc_cb.dll!wxWindowBase::TryAfter+0x58
000007FEE65957C8 0000000000000000 000000000308F3B0 00000000002FF1B0  wxmsw32u_gcc_cb.dll!wxWindowBase::TryAfter+0x58
000007FEE6274EDB 000000000308F3B0 00000000002FF1B0 0000000000141598  wxmsw32u_gcc_cb.dll!wxEvtHandler::SafelyProcessEvent+0xb
000007FEE645D973 0000000000000000 0000000000141598 0000000000000000  wxmsw32u_gcc_cb.dll!wxTreeCtrl::MSWOnNotify+0x133
000007FEE6379D15 00000000009EB780 000000007787B4EF 0000000000000000  wxmsw32u_gcc_cb.dll!wxWindow::MSWHandleMessage+0x995
000007FEE6365EFC 0000000000141598 0000000000000001 0000000000000000  wxmsw32u_gcc_cb.dll!wxWindow::MSWWindowProc+0x2c
0000000077609861 00000000009EB780 000007FEE636E420 00000000FFFFFE0E  USER32.dll!TranslateMessageEx+0x291
000000007760674C 00000000000907DA 000000000000004E 00000000000002EC  USER32.dll!SetTimer+0x16c
0000000077606851 000000000308F3B0 00000000000002EC 000000000308F3B0  USER32.dll!SendMessageW+0x5d
000007FEE645C5E7 FFFFFFFFFFFFFFFF 0000000000000000 0000000000000000  wxmsw32u_gcc_cb.dll!wxTreeCtrl::MSWWindowProc+0x6d7
0000000077609861 00000000002FF6E0 000007FEE636E420 00000000009EB780  USER32.dll!TranslateMessageEx+0x291
0000000077609572 0000000000000000 0000000000000000 000007FEE636E420  USER32.dll!TranslateMessage+0x1de
000000007760646E 0000000002369820 000007FEE6CF8EB0 00000000002FF6E0  USER32.dll!IsDialogMessageW+0x102
000007FEE6369330 0000000006E2B690 000007FEE63B8C64 0000000006BF5610  wxmsw32u_gcc_cb.dll!wxWindow::MSWSafeIsDialogMessage+0xd0
000007FEE63695D9 000000000308F3B0 0000000000000001 0000000000000000  wxmsw32u_gcc_cb.dll!wxWindow::MSWProcessMessage+0x79
000007FEE639A4A0 00000000002FF720 000007FEE6589930 0000000000000000  wxmsw32u_gcc_cb.dll!wxGUIEventLoop::PreProcessMessage+0x110
000007FEE639A7EF 0000000006ECAF30 0000000000010000 0000000006ECAF30  wxmsw32u_gcc_cb.dll!wxGUIEventLoop::Dispatch+0x13f
000007FEE61547E3 0000000000000002 0000000000000040 0000000000000000  wxmsw32u_gcc_cb.dll!wxEventLoopManual::ProcessEvents+0x33
000007FEE61548F8 00000000004BE230 0000000006ECAF30 0000000000000000  wxmsw32u_gcc_cb.dll!wxEventLoopManual::DoRun+0xf8
000007FEE61545C8 0000000000000008 0000000006ECAF30 00000000004BDA30  wxmsw32u_gcc_cb.dll!wxEventLoopBase::Run+0x58
000007FEE6126040 0000000000000030 000007FEE71C7B40 0000000000000000  wxmsw32u_gcc_cb.dll!wxAppConsoleBase::MainLoop+0x70
000000013F0A5E56 00000000004BE230 000007FEE627F9FF 00000000004BDA40  codeblocks.exe!0x5e56
000007FEE6198EF1 00000000004BDA30 000000000000000C 00000000004BDA40  wxmsw32u_gcc_cb.dll!wxEntryReal+0x51
000000013F0A2585 000000013F0A0000 0000000000000000 000000000032323C  codeblocks.exe!0x2585
000000013F0A13AE 0000000000000000 0000000000000000 0000000000000000  codeblocks.exe!0x13ae
000000013F0A14C6 0000000000000000 0000000000000000 0000000000000000  codeblocks.exe!0x14c6
000000007770556D 0000000000000000 0000000000000000 0000000000000000  kernel32.dll!BaseThreadInitThunk+0xd
000000007786372D 0000000000000000 0000000000000000 0000000000000000  ntdll.dll!RtlUserThreadStart+0x1d

I also upload the gif file of the operation.

Thanks.
Title: Re: bug report: C::B crash when I remove the target from a cbp
Post by: AndrewCot on October 17, 2022, 05:58:47 am
I just loaded a copy of my CodeBlocks_Windows.cbp and deleted a few targets and did not get the crash. I closed C::B and reloaded the cbp file and deleted some more targets and it did not crash. I am using SVN 12979 (same code as 129879 , but with updated SVG files) built with MSYS2 Mingw64 GCC 12.2 (last updated about 6 hrs ago).

I then tried with the nightly 12969 and did not get a crash. I tried with both the latest MSYS2 MinGW64 libstdc++-6.dll and the nightly official DLL from 2018 and still did not get a crash.
Can you try the nightly 12969and see if it crashes?


Title: Re: bug report: C::B crash when I remove the target from a cbp
Post by: ollydbg on October 17, 2022, 06:04:39 am
Hi, AndrewCot, thanks for the test. I will try the official nightly build.

My guess is that I have some macro(global compiler variable) in the cbp, for example:

Code
<Add option="`$(#WX_CONFIG) --cflags`" />

Do you have such kinds of macros in the cbp?
Title: Re: bug report: C::B crash when I remove the target from a cbp
Post by: AndrewCot on October 17, 2022, 06:33:21 am
I have a bunch of macros, but this one does not have the wx-config macro. Attached is the original project file before I did any testing.

I just tested with my old (as in I have not touched it in a month ) MSSY2 proejct file that uses  wx-config macro and it does not crash with 12979. I have also attached it.
Title: Re: bug report: C::B crash when I remove the target from a cbp
Post by: Pecan on October 17, 2022, 07:34:27 am
I see that just before the crash ConfigManager::GetUserDataFolder() was called.
But I don't see (in the crash report) from where it was called.
It can only be called from
Code
void ConfigManager::InitPaths()
{
    ConfigManager::config_folder = ConfigManager::GetUserDataFolder();
or
Code
wxString CfgMgrBldr::FindConfigFile(const wxString& filename)
{

    wxString u(ConfigManager::GetUserDataFolder() + wxFILE_SEP_PATH + filename);

GetUserDataFolder() does some weird things.
Code
inline wxString ConfigManager::GetUserDataFolder()
{
    if (has_alternate_user_data_path)
        return alternate_user_data_path;
#ifdef __WINDOWS__
    TCHAR buffer[MAX_PATH];
    if (!ConfigManager::has_alternate_user_data_path && ::GetEnvironmentVariable(_T("APPDATA"), buffer, MAX_PATH))
        return wxString::Format(_T("%s\\CodeBlocks"), buffer);
    else
        return wxStandardPathsBase::Get().GetUserDataDir();
#else
#ifdef __linux__
    gchar *filename = g_build_filename(g_get_user_config_dir(), "codeblocks", nullptr);
    wxString result=wxString::FromUTF8(filename);
    g_free(filename);
    return result;
#else
    return wxStandardPathsBase::Get().GetUserDataDir();
#endif // __linux__
#endif // __WINDOWS__
}

It calls:
Code
if (!ConfigManager::has_alternate_user_data_path && ::GetEnvironmentVariable(_T("APPDATA"), buffer, MAX_PATH))

Where GetEnvironmentVariable() is declared as (in my system)
Code
 __MINGW_NAME_AW(GetEnvironmentVariable)
  WINBASEAPI DWORD WINAPI GetEnvironmentVariableA (LPCSTR lpName, LPSTR lpBuffer, DWORD nSize);
  WINBASEAPI DWORD WINAPI GetEnvironmentVariableW (LPCWSTR lpName, LPWSTR lpBuffer, DWORD nSize);

#define GetEnvironmentVariable
in msys64_13.0.1\mingw64\include\processenv.h
where it crashed in libstdc++-6.dll;

What in the world is it doing.
Or might there be some mixed up system dll's in your system. (Just trying a guess)

Maybe try a full build and see if the problem goes away.
Title: Re: bug report: C::B crash when I remove the target from a cbp
Post by: ollydbg on October 17, 2022, 07:47:41 am
Hi, I can reproduce this crash in the nightly build rev 12969 release.

I just tested the pure nightly build release, no crash.
But when I add the clangd_client(that is: ClangdClientForCBNightly_221008_rev12969_win64-2.zip (https://sourceforge.net/projects/cb-clangd-client/files/Plugin_Install_Package/Windows_x64/ClangdClientForCBNightly_221008_rev12969_win64-2.zip/download)), the same step, C::B will crash.

So, does this mean the crash is from the clangd_client?

Here is the call stack of the crash in the nightly build rev 12969:

Code
Error occurred on Monday, October 17, 2022 at 13:43:55.

codeblocks.exe caused an Access Violation at location 000000006FF082D8 in module codeblocks.dll Reading from location FFFFFFFFFFFFFFFF.

AddrPC           Params
000000006FF082D8 0000000009B0C440 000000000A3CF1D0 0000000000000000  codeblocks.dll!MacrosManager::RecalcVars
000000006FF0CEB6 0000000009B0C440 0000000000229610 000000000A3CFA10  codeblocks.dll!MacrosManager::ReplaceMacros
000000006FF313C4 000000000A4F8740 000000000A3CFA10 000000000A3E7320  codeblocks.dll!ProjectFile::CompareProjectFiles
000000006FF30C8E 000000000A3E7320 000000000A3CFA10 000000000022AA80  codeblocks.dll!ProjectFile::DoUpdateFileDetails
000000006FF30BBA 000000000A3E7320 0000000000000000 000000000A3CF100  codeblocks.dll!ProjectFile::UpdateFileDetails
00000000004ACEE5 000000000A3CF1D0 000000000A3CF3C8 0000000000000003  codeblocks.exe!0xacee5
00000000004A2191 0000000002573CA0 000000000022B5A0 0000000C00000000  codeblocks.exe!0xa2191
00000000623C3184 00000000035190E0 000000000039F708 0000000000000000  wxmsw32u_gcc_cb.dll!wxAppConsoleBase::CallEventHandler
000000006251E302 0000000003282E60 0000000000000001 0000000000000000  wxmsw32u_gcc_cb.dll!wxEvtHandler::ProcessEventIfMatchesId
000000006251E4C7 0000000002573CA0 0000000000000000 00000000022200D1  wxmsw32u_gcc_cb.dll!wxEventHashTable::HandleEvent
000000006251EB1D 0000000000000020 00000000FFFFFF11 0000000000301612  wxmsw32u_gcc_cb.dll!wxEvtHandler::TryHereOnly
000000006251E5A3 00000000024876F0 000000000022B5A0 0000000000000000  wxmsw32u_gcc_cb.dll!wxEvtHandler::DoTryChain
000000006251EC71 0000000002A7E8F0 000000000022B5A0 00000000FFFFFFFF  wxmsw32u_gcc_cb.dll!wxEvtHandler::ProcessEvent
0000000062877A08 0000000002A7E8F0 000000006252090B 00000000006DE260  wxmsw32u_gcc_cb.dll!wxWindowBase::TryAfter
0000000062877A08 000000000022B5A0 0000000063313BA0 000000000022C200  wxmsw32u_gcc_cb.dll!wxWindowBase::TryAfter
000000006252090B 0000000000000000 0000000000000001 0000000000000000  wxmsw32u_gcc_cb.dll!wxEvtHandler::SafelyProcessEvent
000000006281742A 0000000000000000 0000000000000000 0000000000000000  wxmsw32u_gcc_cb.dll!wxMenuBase::SendEvent
00000000626CEB52 0000000000000001 0000000062635A0F FFFFFFFF00000000  wxmsw32u_gcc_cb.dll!wxMenu::MSWCommand
0000000062634D3E 000000000000000D 000000000022B980 000000000022B9B0  wxmsw32u_gcc_cb.dll!wxWindow::HandleCommand
000000006263FFBA 0000000065343A62 0000000000000000 0000000002A70E90  wxmsw32u_gcc_cb.dll!wxWindow::MSWHandleMessage
000000006262F9FC 0000000000000001 000000006251E302 0000000002A0D120  wxmsw32u_gcc_cb.dll!wxWindow::MSWWindowProc
0000000062731B30 0000000000000000 0000000000000038 000000000022BF28  wxmsw32u_gcc_cb.dll!wxTreeCtrl::MSWWindowProc
0000000077609861 000000000022C010 0000000062637930 000000000022C200  USER32.dll!TranslateMessageEx
0000000077609572 000000000022C010 000000000022C010 0000000062637930  USER32.dll!TranslateMessage
0000000062631A05 000000000022EC40 00000000006DE260 0000000002A7E8F0  wxmsw32u_gcc_cb.dll!wxWindow::DoPopupMenu
0000000062873C24 000000000022C2B8 000000000022EC40 00000000630D2000  wxmsw32u_gcc_cb.dll!wxWindowBase::PopupMenu
00000000004F56EB 0000000002A7E8F0 000000000022C200 000000000022E818  codeblocks.exe!0xf56eb
0000000000499872 0000000002573CA0 00000000058008A0 000000000022E818  codeblocks.exe!0x99872
000000000049D93E 0000000002573CA0 000000000022EC40 0000000000251042  codeblocks.exe!0x9d93e
00000000623C3184 0000000000000000 0000000000000001 0000000000000000  wxmsw32u_gcc_cb.dll!wxAppConsoleBase::CallEventHandler
000000006251E302 000000000022EA94 000000006272C0C1 000000000022EC40  wxmsw32u_gcc_cb.dll!wxEvtHandler::ProcessEventIfMatchesId
000000006251E4C7 0000000002573CA0 0000000000000000 0000000000001111  wxmsw32u_gcc_cb.dll!wxEventHashTable::HandleEvent
000000006251EB1D 000000000022EE40 00000000000002EC 0000000000251042  wxmsw32u_gcc_cb.dll!wxEvtHandler::TryHereOnly
000000006251E5A3 00000000024876F0 000000000022EC40 0000000000000000  wxmsw32u_gcc_cb.dll!wxEvtHandler::DoTryChain
000000006251EC71 0000000002A7E8F0 000000000022EC40 000000000022F4A0  wxmsw32u_gcc_cb.dll!wxEvtHandler::ProcessEvent
0000000062877A08 000000000DA0E270 00000000000002EC 0000000000002803  wxmsw32u_gcc_cb.dll!wxWindowBase::TryAfter
0000000062877A08 0000000000000000 0000000002A7E8F0 000000000022EC40  wxmsw32u_gcc_cb.dll!wxWindowBase::TryAfter
000000006252090B 0000000002A7E8F0 000000000022EC40 00000000FFFFFE0E  wxmsw32u_gcc_cb.dll!wxEvtHandler::SafelyProcessEvent
0000000062733307 0000000000000000 0000000000000020 0000000000000000  wxmsw32u_gcc_cb.dll!wxTreeCtrl::MSWOnNotify
000000006263F12C 0000000000000000 0000000000000002 000000000022F170  wxmsw32u_gcc_cb.dll!wxWindow::MSWHandleMessage
000000006262F9FC 0000000000301612 0000000000000001 0000000000000000  wxmsw32u_gcc_cb.dll!wxWindow::MSWWindowProc
0000000077609861 0000000000DB3B90 0000000062637930 00000000FFFFFE0E  USER32.dll!TranslateMessageEx
000000007760674C 0000000000251042 000000000000004E 00000000000002EC  USER32.dll!SetTimer
0000000077606851 0000000002A7E8F0 00000000000002EC 0000000000000000  USER32.dll!SendMessageW
000000006273224F 0000000000000001 0000000000000000 0000000000000000  wxmsw32u_gcc_cb.dll!wxTreeCtrl::MSWWindowProc
0000000077609861 000000000022FA10 0000000062637930 0000000000DB3B90  USER32.dll!TranslateMessageEx
0000000077609572 0000000000000000 0000000000000000 0000000062637930  USER32.dll!TranslateMessage
000000007760646E 00000000024876F0 0000000077607BC2 00000000FFFFFFEC  USER32.dll!IsDialogMessageW
000000006263245B 000000000A383400 000000006267E94B 0000000000000001  wxmsw32u_gcc_cb.dll!wxWindow::MSWSafeIsDialogMessage
00000000626326A9 0000000002A7E8F0 0000000000000001 0000000000000000  wxmsw32u_gcc_cb.dll!wxWindow::MSWProcessMessage
00000000626620AA 000000000A396700 0000000000000000 000000000022FA30  wxmsw32u_gcc_cb.dll!wxGUIEventLoop::PreProcessMessage
0000000062661F71 00000000006DE260 00000000623C552F 000000000A396740  wxmsw32u_gcc_cb.dll!wxGUIEventLoop::ProcessMessage
0000000062661D81 000000000A3833E0 0000000000010000 000000000A3833E0  wxmsw32u_gcc_cb.dll!wxGUIEventLoop::Dispatch
00000000623F6653 000000000A3833E0 000007FEFDF913D2 0000000000000002  wxmsw32u_gcc_cb.dll!wxEventLoopManual::ProcessEvents
00000000623F673E 00000000006DE260 000000000A3833E0 0000000000000010  wxmsw32u_gcc_cb.dll!wxEventLoopManual::DoRun
00000000623F63B9 0000000000000040 0000000200000040 000000000A3833E0  wxmsw32u_gcc_cb.dll!wxEventLoopBase::Run
00000000623C7CBA 00000000006DE820 000000006263B31E 00000000006DE830  wxmsw32u_gcc_cb.dll!wxAppConsoleBase::MainLoop
0000000000405D2E 00000000006DE260 000000006252AFBB 00000000006DDA40  codeblocks.exe!0x5d2e
000000006243E635 0000000000000010 000000000000000C 00000000006DDA40  wxmsw32u_gcc_cb.dll!wxEntryReal
000000000040255C 0000000000400000 0000000000000000 00000000007A3281  codeblocks.exe!0x255c
00000000004013C7 0000000000000000 0000000000000000 0000000000000000  codeblocks.exe!0x13c7
00000000004014CB 0000000000000000 0000000000000000 0000000000000000  codeblocks.exe!0x14cb
000000007770556D 0000000000000000 0000000000000000 0000000000000000  kernel32.dll!BaseThreadInitThunk
000000007786372D 0000000000000000 0000000000000000 0000000000000000  ntdll.dll!RtlUserThreadStart


The crash is exact the same as my original crash report(which I used my own C::B and clangd_client).
Title: Re: bug report: C::B crash when I remove the target from a cbp
Post by: AndrewCot on October 17, 2022, 08:45:54 am
I am using a local build of clangd_client r85 ( clangd_client 0.2.47 22/10/15) that is included in the top level workspace that I use to build the 12979 and it does not crash on me. As Pecan posted try a full rebuild and see how you go, but be sure to try building the  clangd_client as a separate step so that C::B and the clangd_clientare in sync.

I am not using clangd_client  with the nightly.
Title: Re: bug report: C::B crash when I remove the target from a cbp
Post by: ollydbg on October 17, 2022, 10:31:52 am
I just tried to rebuild the whole C::B and the clangd_client plugin, and I tested it again. The same steps, if the clangd_client plugin is enabled, removing a target from the cbp will cause the crash.
If clangd_client plugin is disabled, there is no crash here by those steps. So, the local build C::B test result is exact the same as the official nightly build release.
Title: Re: bug report: C::B crash when I remove the target from a cbp
Post by: AndrewCot on October 17, 2022, 01:04:58 pm
I have been able to re-create the crash with the nightly and the clangd-client from the ClangdClientForCBNightly_221008_rev12969_win64-2.zip file, but the crash does not always occur.
I think it could be that if you delete a project where a file (or files) is/are being parsed then you get the crash, but I need to do more testing. Unfortunately it's getting late and I am calling it a night.
My crash report is slightly different in that I have some clangd_client.dll entries.

Code
-------------------

Error occurred on Monday, October 17, 2022 at 21:56:59.

codeblocks.exe caused an Access Violation at location 0000000000000000 DEP violation at location 0000000000000000.

AddrPC           Params
0000000000000000 000000000B264AD8 0000000063103D60 0000000000000000
000000006FF082DA 000000000B2648B0 000000000BCF2190 0000000010BD5070  codeblocks.dll!MacrosManager::RecalcVars
000000006FF0CEB6 000000000B2648B0 0000000000836840 000000000C0137B0  codeblocks.dll!MacrosManager::ReplaceMacros
000000006FF313C4 0000000011FBC220 000000000C0137B0 00000000111B1B00  codeblocks.dll!ProjectFile::CompareProjectFiles
000000006FF31101 0000000011FBC220 000000000C0137B0 00000000111B1B00  codeblocks.dll!ProjectFile::CompareProjectFiles
000000006FF30CB0 00000000111B1B00 000000000C0137B0 00000000008377F0  codeblocks.dll!ProjectFile::DoUpdateFileDetails
000000006FF30D4B 00000000111B1B00 000000000C0137B0 0000000000240064  codeblocks.dll!ProjectFile::GetFileDetails
0000000007CDFEFE 00000000008385C0 000000000BE8D350 000000000C0137B0  clangd_client.dll!GetCompileFileCommand  [F:/usr/Proj/Clangd_Client-WORK/trunk/clangd_client/src/LSPclient/client.cpp @ 3376]
0000000007CE1513 000000000BE8D350 000000000BCF2190 000000000C0137B0  clangd_client.dll!AddFileToCompileDBJson  [F:/usr/Proj/Clangd_Client-WORK/trunk/clangd_client/src/LSPclient/client.cpp @ 3565]
0000000007CE2A53 000000000BE8D350 000000000BCF2190 0000000000839330  clangd_client.dll!UpdateCompilationDatabase  [F:/usr/Proj/Clangd_Client-WORK/trunk/clangd_client/src/LSPclient/client.cpp @ 3763]
0000000007CD1B9B 000000000BE8D350 0000000000839920 000000000BCF2190  clangd_client.dll!LSP_DidOpen  [F:/usr/Proj/Clangd_Client-WORK/trunk/clangd_client/src/LSPclient/client.cpp @ 1980]
0000000007CA0C29 000000000C0A9610 0000000000839DA0 00000000000309A8  clangd_client.dll!OnLSP_BatchTimer  [F:/usr/Proj/Clangd_Client-WORK/trunk/clangd_client/src/codecompletion/parser/parser.cpp @ 1079]
00000000623C3184 0000000000000200 0000000000000001 00000000000C0022  wxmsw32u_gcc_cb.dll!wxAppConsoleBase::CallEventHandler
000000006251E302 0000000010B949E0 000000006267EAFF 000000000000113E  wxmsw32u_gcc_cb.dll!wxEvtHandler::ProcessEventIfMatchesId
000000006251E794 0000000000000001 00007FFE9DEAC500 0000000062FDEB50  wxmsw32u_gcc_cb.dll!wxEvtHandler::SearchDynamicEventTable
Title: Re: bug report: C::B crash when I remove the target from a cbp
Post by: ollydbg on October 17, 2022, 02:54:18 pm
Hi, AndrewCot, thanks for the help.

I run clangd_client in the debugger, and I found a call stack when crashed:

Code

#0  0x000007fee354b565 in MacrosManager::RecalcVars (this=0x5e014b0, project=0x6723a40, editor=0x0, target=0x67715d0) at D:\code\cbsource\cb_svn_git\src\sdk\macrosmanager.cpp:242
#1  0x000007fee3550134 in MacrosManager::ReplaceMacros (this=0x5e014b0, buffer=..., target=0x67715d0, subrequest=false) at D:\code\cbsource\cb_svn_git\src\sdk\macrosmanager.cpp:589
#2  0x000007fee3574faa in pfDetails::Update (this=0x675cd30, target=0x67715d0, pf=0x676b170) at D:\code\cbsource\cb_svn_git\src\sdk\projectfile.cpp:402
#3  0x000007fee3574875 in ProjectFile::DoUpdateFileDetails (this=0x676b170, target=0x67715d0) at D:\code\cbsource\cb_svn_git\src\sdk\projectfile.cpp:318
#4  0x000007fee3574795 in ProjectFile::UpdateFileDetails (this=0x676b170, target=0x0) at D:\code\cbsource\cb_svn_git\src\sdk\projectfile.cpp:303
#5  0x000000013f9304a5 in (anonymous namespace)::ProjectShowOptions (project=0x6723a40) at D:\code\cbsource\cb_svn_git\src\src\projectmanagerui.cpp:3656
#6  0x000000013f92567c in ProjectManagerUI::OnProperties (this=0x2d7e110, event=...) at D:\code\cbsource\cb_svn_git\src\src\projectmanagerui.cpp:1967
#7  0x000007fee8962e77 in wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#8  0x000007fee8ab2aa5 in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#9  0x000007fee8ab2c8b in wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#10 0x000007fee8ab32cd in wxEvtHandler::TryHereOnly(wxEvent&) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#11 0x000007fee8ab2d73 in wxEvtHandler::DoTryChain(wxEvent&) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#12 0x000007fee8ab3421 in wxEvtHandler::ProcessEvent(wxEvent&) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#13 0x000007fee8dd57c8 in wxWindowBase::TryAfter(wxEvent&) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#14 0x000007fee8dd57c8 in wxWindowBase::TryAfter(wxEvent&) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#15 0x000007fee8ab4edb in wxEvtHandler::SafelyProcessEvent(wxEvent&) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#16 0x000007fee8d7c8aa in wxMenuBase::SendEvent(int, int) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#17 0x000007fee8c3ff9d in wxMenu::MSWCommand(unsigned int, unsigned short) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#18 0x000007fee8bba64b in wxWindow::MSWHandleMessage(long long*, unsigned int, unsigned long long, long long) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#19 0x000007fee8ba5efc in wxWindow::MSWWindowProc(unsigned int, unsigned long long, long long) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#20 0x0000000077009bbd in USER32!TranslateMessageEx () from C:\Windows\system32\user32.dll
#21 0x00000000770098c2 in USER32!TranslateMessage () from C:\Windows\system32\user32.dll
#22 0x000007fee8ba7e71 in wxWindow::DoPopupMenu(wxMenu*, int, int) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#23 0x000007fee8dd0fc4 in wxWindowBase::PopupMenu(wxMenu*, int, int) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#24 0x000000013f9796cc in wxWindowBase::PopupMenu (this=0x2c4ef00, menu=0x38bad0, pos=...) at D:\code\wxWidgets-3.2.1\include\wx\window.h:1370
#25 0x000000013f91cc7b in ProjectManagerUI::ShowMenu (this=0x2d7e110, id=..., pt=...) at D:\code\cbsource\cb_svn_git\src\src\projectmanagerui.cpp:915
#26 0x000000013f920dcb in ProjectManagerUI::OnTreeItemRightClick (this=0x2d7e110, event=...) at D:\code\cbsource\cb_svn_git\src\src\projectmanagerui.cpp:1327
#27 0x000007fee8962e77 in wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#28 0x000007fee8ab2aa5 in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#29 0x000007fee8ab2c8b in wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#30 0x000007fee8ab32cd in wxEvtHandler::TryHereOnly(wxEvent&) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#31 0x000007fee8ab2d73 in wxEvtHandler::DoTryChain(wxEvent&) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#32 0x000007fee8ab3421 in wxEvtHandler::ProcessEvent(wxEvent&) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#33 0x000007fee8dd57c8 in wxWindowBase::TryAfter(wxEvent&) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#34 0x000007fee8dd57c8 in wxWindowBase::TryAfter(wxEvent&) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#35 0x000007fee8ab4edb in wxEvtHandler::SafelyProcessEvent(wxEvent&) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#36 0x000007fee8c9d973 in wxTreeCtrl::MSWOnNotify(int, long long, long long*) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#37 0x000007fee8bb9d15 in wxWindow::MSWHandleMessage(long long*, unsigned int, unsigned long long, long long) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#38 0x000007fee8ba5efc in wxWindow::MSWWindowProc(unsigned int, unsigned long long, long long) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#39 0x0000000077009bbd in USER32!TranslateMessageEx () from C:\Windows\system32\user32.dll
#40 0x0000000077006a5c in USER32!SetTimer () from C:\Windows\system32\user32.dll
#41 0x0000000077006b61 in USER32!SendMessageW () from C:\Windows\system32\user32.dll
#42 0x000007fee8c9c5e7 in wxTreeCtrl::MSWWindowProc(unsigned int, unsigned long long, long long) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#43 0x0000000077009bbd in USER32!TranslateMessageEx () from C:\Windows\system32\user32.dll
#44 0x00000000770098c2 in USER32!TranslateMessage () from C:\Windows\system32\user32.dll
#45 0x0000000077006782 in USER32!IsDialogMessageW () from C:\Windows\system32\user32.dll
#46 0x000007fee8ba9330 in wxWindow::MSWSafeIsDialogMessage(tagMSG*) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#47 0x000007fee8ba95d9 in wxWindow::MSWProcessMessage(tagMSG*) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#48 0x000007fee8bda4a0 in wxGUIEventLoop::PreProcessMessage(tagMSG*) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#49 0x000007fee8bda7ef in wxGUIEventLoop::Dispatch() () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#50 0x000007fee89947e3 in wxEventLoopManual::ProcessEvents() () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#51 0x000007fee89948f8 in wxEventLoopManual::DoRun() () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#52 0x000007fee89945c8 in wxEventLoopBase::Run() () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#53 0x000007fee8966040 in wxAppConsoleBase::MainLoop() () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#54 0x000000013f885e56 in CodeBlocksApp::OnRun (this=0x1d6dfd0) at D:\code\cbsource\cb_svn_git\src\src\app.cpp:907
#55 0x000007fee89d8ef1 in wxEntryReal(int&, wchar_t**) () from D:\code\wxWidgets-3.2.1\lib\gcc_dll\wxmsw32u_gcc_cb.dll
#56 0x000000013f882585 in WinMain (hInstance=0x13f880000, hPrevInstance=0x0, lpCmdLine=0x48376c "--debug-log --no-dde --no-check-associations --multiple-instance  --verbose --no-splash-screen  /p cbDebug320", nCmdShow=10) at D:\code\cbsource\cb_svn_git\src\src\app.cpp:327
#57 0x000000013f8813ae in __tmainCRTStartup () at C:/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:329
#58 0x000000013f8814c6 in WinMainCRTStartup () at C:/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:176


EDIT:

But strange that my call-stack does not come from the clangd_client source code.
Title: Re: bug report: C::B crash when I remove the target from a cbp
Post by: Pecan on October 17, 2022, 05:48:15 pm
Hi, AndrewCot, thanks for the help.

I run clangd_client in the debugger, and I found a call stack when crashed

But strange that my call-stack does not come from the clangd_client source code.

<partial quote>

@ ollydbg
Copy the clangd_client.dll with the debugger symbols over the clangd_client that you're using and see if you get the clangd_client entries in the crash report.

This is beginning to make some sense. Clangd_client doesn't handle the "target deleted" event.

After the crash would you guys look to see if you have a C:\temp\CBclangd_client-xxxxx.log where xxxxxx can be determined by issuing command this command after the project is loaded but before replicating the crash:
Code
tasklist /nh /fi "IMAGENAME eq clangd*"

<Output from command>
clangd.exe                   35008 Console                   18     20,264 K
clangd.exe                   27712 Console                   18    566,080 K <----- xxxxxx is pid 27712 for me.

The last entry produced by this command should be the appropriate xxxxx to identify the .log file.

Example logs:
Code
C:\temp\CBclangd_client-23724.log
C:\temp\CBclangd_client-27712.log <--------
C:\temp\CBclangd_client-29996.log
C:\temp\CBclangd_client-35008.log
C:\temp\CBclangd_client-35252.log
C:\temp\CBclangd_LogsIndex.txt
C:\temp\CBclangd_server-23724.log
C:\temp\CBclangd_server-35252.log

Or, after loading the project issue the command:
Code
del c:\temp\CBclangd*.log

It will not delete open logs. It will remove unneeded logs.

c:\temp\CBclangd_client-17072.log
The process cannot access the file because it is being used by another process.
c:\temp\CBclangd_client-35008.log
The process cannot access the file because it is being used by another process.
Title: Re: bug report: C::B crash when I remove the target from a cbp
Post by: Pecan on October 17, 2022, 09:01:32 pm
@ ollydbg and Andrew

Nerver mind. I caught the crash.
It's happening when clangd_client calls:
pProjectFile->GetBuildTargets();
in UpdateCompilationDatabase()

It's actually handing back a list of targets which contains the target I just deleted.

Gotta figure this one out......  >:(

Title: Re: bug report: C::B crash when I remove the target from a cbp
Post by: ollydbg on October 18, 2022, 02:40:07 am
Hi, Pecan, good news that you find the reason.

About the call stack, I was using cb to debug cb, and I do have debug information in generated dll and exe files, which also includes the clangd_client in the devel folder.

My previous post contains call stack from gdb, but still no info from clangd_client.  :(
Title: Re: bug report: C::B crash when I remove the target from a cbp
Post by: Pecan on October 18, 2022, 02:44:04 am
Fixed in  Head 12982.

Modified cbProject - Fix crash in MacrosManager using bad m_LastTarget pointer.

Modified RemoveBuildTarget() to reset MacrosManager pointers.
The macro manager stores pointers to projects and targets, so we need to clear it to prevent dangling pointer bugs

Edit: Added the comment and forgot to add the code.
Done again.
Title: Re: bug report: C::B crash when I remove the target from a cbp
Post by: ollydbg on October 18, 2022, 04:03:56 am
Fixed in  Head 12982.

Modified cbProject - Fix crash in MacrosManager using bad m_LastTarget pointer.

Modified RemoveBuildTarget() to reset MacrosManager pointers.
The macro manager stores pointers to projects and targets, so we need to clear it to prevent dangling pointer bugs

Edit: Added the comment and forgot to add the code.
Done again.

Hi, Pecan, thanks for the fix.

I can confirm that with the rev 12982, the crash issue is gone.  :)
Title: Re: bug report: C::B crash when I remove the target from a cbp
Post by: AndrewCot on October 18, 2022, 09:50:35 am
I can also confirm no crash.
I spotted that after I deleted the C::B SDK target as the clangd_client kept parsing the SDK files (after pressing the OK button and waiting a few seconds). I suspect the files were queued to be processed and the queue was not reset/updated/fixed due to the SDK target being deleted. I think this could be logged as a bug, but as it does not cause any issues that I could see the bug could wait until some time in the future to fix when time permits. Does this sound okay? (Raise a bug and fix it when time permits.)


Title: Re: bug report: C::B crash when I remove the target from a cbp
Post by: Pecan on October 18, 2022, 05:59:14 pm
I can also confirm no crash.
I spotted that after I deleted the C::B SDK target as the clangd_client kept parsing the SDK files (after pressing the OK button and waiting a few seconds). I suspect the files were queued to be processed and the queue was not reset/updated/fixed due to the SDK target being deleted. I think this could be logged as a bug, but as it does not cause any issues that I could see the bug could wait until some time in the future to fix when time permits. Does this sound okay? (Raise a bug and fix it when time permits.)

I'll log this into the clangd_client ticket systems.

Thanks guys.
Title: Re: bug report: C::B crash when I remove the target from a cbp
Post by: Pecan on October 18, 2022, 06:01:55 pm
I can also confirm no crash.
I spotted that after I deleted the C::B SDK target as the clangd_client kept parsing the SDK files (after pressing the OK button and waiting a few seconds). I suspect the files were queued to be processed and the queue was not reset/updated/fixed due to the SDK target being deleted. I think this could be logged as a bug, but as it does not cause any issues that I could see the bug could wait until some time in the future to fix when time permits. Does this sound okay? (Raise a bug and fix it when time permits.)

@ Andrew
What was the message you on which you had to click ok.
It might help me to find exactly where the problem lies.

Edit: Never mind, I think you meant the target delete confirmation.

This is a rough one. The background queue can validly contain files that do not belong to a project or target.
And, the target is deleted before the cbEVT_BUILDTARGET_REMOVED event is issued, thus wiping out any info for comparison of background queue to target files.
Title: Re: bug report: C::B crash when I remove the target from a cbp
Post by: Pecan on October 18, 2022, 08:28:01 pm
Re: Clangd_client keeps parsing after target deletion.

There already is code in the parsers waiting queue to check that the file about to be parsed belongs to a project.
Code
        ProjectFile* pf = m_Project->GetFileByFilename(list->GetString(i));
        if (!pf)
            break;

So those sdk target files must have other targets referencing them. Or, there's an error in CB.

Since both old CodeCompletion and Clangd_client work at the project level, I'm pretty sure the code is correct.
But I can test like:
Code
pseudo code:
If file belongs to a project, and ProjectFile-GetTargets() returns zero targets, Do Not parse this file.

But I think that this is useless effort. I betcha it'll return a target every time. Since most projects have at least a release and debug target, one of them will always report that it owns the file. Especially in that CB will not let you delete a target if it's a single target project.

But I'll test deleting the sdk target anyway.