Code::Blocks

User forums => Help => Topic started by: cacb on May 06, 2019, 09:15:09 am

Title: Tools Menu item causing wxWidgets Debug alert in C::B
Post by: cacb on May 06, 2019, 09:15:09 am
Hi, I am using Code::Blocks nightly build svn 11628 under Windows 10 and Windows 7 and seeing this issue in both places.

I use git for source control and find it convenient to add a "Git Gui Here" item in the basic Tools menu of Code::Blocks. However, when I use this option I am almost always (not 100% of the time though) met with a "wxWidgets Debug Alert"  'threatening' to crash the IDE unless I ask it not to. When I reply 'No' it all works as expected, the git gui appears.

Btw. I use the same basic git gui on linux as well, with no issues.

So the question is: What is causing this, and is there anything I can do to prevent it from happening under Windows?


Title: Re: Tools Menu item causing wxWidgets Debug alert in C::B
Post by: oBFusCATed on May 06, 2019, 10:53:41 am
Someone with a windows build should spend some time to see why this happens.
From the docs a possible cause is incorrect return value by git.exe.
Can you switch to "Launch the tool visible detached" and report if it fixes the problem?
Title: Re: Tools Menu item causing wxWidgets Debug alert in C::B
Post by: cacb on May 06, 2019, 11:10:31 am
Someone with a windows build should spend some time to see why this happens.
From the docs a possible cause is incorrect return value by git.exe.
Can you switch to "Launch the tool visible detached" and report if it fixes the problem?

I tried  "Launch the tool visible detached", but then I just get an unwanted terminal, plus the same Debug Alert window, so it does not fix it. I also tried the other options without success.

It sounds possible that this is something caused by git.exe, since I use the same technique for other things without the same kind of issue. However, git is the most used tool so it would be nice if it worked with git.

Title: Re: Tools Menu item causing wxWidgets Debug alert in C::B
Post by: oBFusCATed on May 06, 2019, 11:27:21 am
Yes, but from MS' docs (https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-getexitcodeprocess):
Quote
Important  The GetExitCodeProcess function returns a valid error code defined by the application only after the thread terminates. Therefore, an application should not use STILL_ACTIVE (259) as an error code. If a thread returns STILL_ACTIVE (259) as an error code, applications that test for this value could interpret it to mean that the thread is still running and continue to test for the completion of the thread after the thread has terminated, which could put the application into an infinite loop.
Title: Re: Tools Menu item causing wxWidgets Debug alert in C::B
Post by: oBFusCATed on May 06, 2019, 11:29:58 am
BTW: This assert is added to wxWidgets 12 ago https://github.com/wxWidgets/wxWidgets/blame/master/src/msw/utilsexc.cpp#L308
Title: Re: Tools Menu item causing wxWidgets Debug alert in C::B
Post by: cacb on May 06, 2019, 01:10:31 pm
Does this mean the problem is in wxWidgets and/or git, and therefore not something to be solved in C::B? It is not entirely clear to me what the conclusion is.
Title: Re: Tools Menu item causing wxWidgets Debug alert in C::B
Post by: oBFusCATed on May 06, 2019, 01:59:23 pm
I don't know.
First you have to check what is the exit code of git. If it is 259 then it is an issue in git, but I doubt it returns this error code, because git is a unix software and there the exit code is 8bit.
After you know the exit code of git we could have a better idea where to look for the problem. I'm not on windows, so I cannot check this.
Title: Re: Tools Menu item causing wxWidgets Debug alert in C::B
Post by: cacb on May 06, 2019, 02:39:35 pm
I don't know.
First you have to check what is the exit code of git. If it is 259 then it is an issue in git, but I doubt it returns this error code, because git is a unix software and there the exit code is 8bit.
After you know the exit code of git we could have a better idea where to look for the problem. I'm not on windows, so I cannot check this.

Ok, I just checked it by opening a cmd.exe terminal window in one of my git folders, and did

git gui

then as the gui was active, i typed in the terminal

echo %errorlevel%

The answer I got was 259

After closing the git gui window, I tried again and got 259 still.

Title: Re: Tools Menu item causing wxWidgets Debug alert in C::B
Post by: oBFusCATed on May 06, 2019, 02:43:04 pm
I guess you have to report this to your vendor of git.exe.

Generally we should build with asserts disabled, but I think for now it is a good idea to do so.
Probably we could replace the assert handler to be less vocal and just to log in the debug log, but I don't know if this is possible at the moment.
Title: Re: Tools Menu item causing wxWidgets Debug alert in C::B
Post by: cacb on May 06, 2019, 03:34:20 pm
I guess you have to report this to your vendor of git.exe.

 ;D I guess this is true, the issue should be reported somewhere. Just to be sure I upgraded to the latest git (git version 2.21.0.windows.1) and checked again. The same happened. So, instead I tried a work-around by writing a MSVC C++ console program called "git_gui", the complete source code follows :

Code: [Select]
#include <windows.h>
#pragma comment (lib,"shell32.lib")
int main()
{
    ShellExecute(0, "open", "git", "gui", NULL, 0);
    return 0;
}


I then reconfigured The tools menu to refer to git_gui.exe instead of git gui and it worked  :P