User forums > General (but related to Code::Blocks)
C::B reports wxRecursionGuards error when loading a cbp project
Pecan:
--- Quote from: blauzahn on October 11, 2025, 03:29:07 am ---I can reproduce the error with wx 3.3.2 on Linux.
The analysers scan-build or cppcheck show several issues with Clangd_client.
--- End quote ---
Would you care to share those issues with us?
Can you tell us how to reproduce the issue?
ollydbg:
I see this issue again and again. Sometimes, the C::B just existed(crashed) without any message, this happens after when I click the "Cancel" button in the message box to continue the application. When I looked at the RPT(call stack), it just empty, so I don't have much information to share.
stahta01:
--- Quote from: ollydbg on Yesterday at 04:28:15 am ---I see this issue again and again. Sometimes, the C::B just existed(crashed) without any message, this happens after when I click the "Cancel" button in the message box to continue the application. When I looked at the RPT(call stack), it just empty, so I don't have much information to share.
--- End quote ---
It is normal for crashing to happen if you click the cancel button in a wxWidgets assert style message; but it should give you a RPT file to help find the location of the crash. I have done it to track down the location where the code needs changed.
Tim S.
Pecan:
Since some users report this assert in relation to clangd_client plugin,
I'll try to recreate the situation and find the cause.
It may take some time since I'm not proficient with Linux.
Gemini 3.0 explains this error as follows:
My query to Gemini 3.0:
--- Code: --- Please explain this message from wxWidgets that occurs more and more with Codeblocks IDE.
wxWidgets Debug Alert
A debugging check in this application has failed.
..\..\include/wx/recguard.h(36): assert "m_flag > 0" failed in ~wxRecursionGuard(): unbalanced wxRecursionGuards!?
Gemini responded;
This specific error is a classic "housekeeping" alert from the wxWidgets library. In short, the program is telling you that it tried to clean up a safety mechanism, but the math didn't add up.
What is a Recursion Guard?
A wxRecursionGuard is a tool developers use to prevent a function from calling itself infinitely (which would crash the program). Think of it like a "Do Not Enter" sign that a function hangs on its door when it starts working. When the function finishes, it takes the sign down.
The error assert "m_flag > 0" failed means that when the function finished and went to take the sign down, it found the sign was already gone - or it found "negative" signs. This is what the message means by "unbalanced."
Why is this happening in Code::Blocks?
Code::Blocks is built using wxWidgets. You are seeing this more often likely due to one of three reasons:
UI Event Races: Code::Blocks is trying to process a UI event (like a mouse click or a window redraw) while another event is still finishing. This is common if you are clicking rapidly or if the IDE is lagging.
Plugin Conflicts: A specific plugin (like Code Completion or Symbol Browser) might be triggering a "re-entrant" call, where it starts a task, gets interrupted, and fails to clean up its state properly.
Build/Version Mismatch: If you recently updated your OS or the IDE, there might be a slight incompatibility in how messages are passed between the system and the wxWidgets layer.
How to Fix or Bypass It
Since this is a Debug Alert, it is technically a warning for the developers of Code::Blocks, not necessarily a sign that your code is broken.
The "Ignore" Method: Click "Yes" to continue (this usually ignores the specific failure) or "No" to stop debugging. If you click "Cancel," it will likely crash the IDE to trigger a debugger.
Update Code::Blocks: Check if there is a newer "Nightly Build" or stable release. These "unbalanced guard" bugs are frequently patched in newer revisions.
Disable Heavy Plugins: Go to Plugins -> Manage plugins and try disabling non-essential ones (like "SpellChecker" or "Occurrences Highlight") to see if the frequency drops.
The "Silent" Route: If it is driving you crazy, you can run the "non-debug" version of Code::Blocks (the release build), which typically strips out these assert checks so they don't pop up.
--- End code ---
clangd_client has some re-entrancy guards. But I do not remember calling wxWidgets to do the guarding.
But I'll check them out to see if there are some logic violations or any use of wxWidgets recursion guards.
Pecan:
The only reference to recguard.h in CB is in headerfixup plugin.
Do any of the posters here (and getting the assert) use headerfixup plugin?
If so, just for testing, please disable the plugin and run without it for awhile and post back your experience.
This is a "Hail Mary" because headerguard does not actually use the wxRecursionGuard code. It only references the name. And no other code in CB uses it either.
So... must be wxWidgets using it itself.
Thanks
Edit: 2026/02/21 10:45:13
Well.. It seems that all code uses it that uses the event loop. This shoud be fun ):
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version