Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: KodamaDeveloped on May 21, 2020, 05:18:32 am

Title: Project wizard crashes CB
Post by: KodamaDeveloped on May 21, 2020, 05:18:32 am
CB20.03, Win10/mingw64.

My project wizard script crashes CB after I upgraded to 20.03, when the script trys to add/remove a target to/from a project in SetupProject primitive function.  That may not always happen, but usually happens just after CB starts with blank workspace.  That can be reproduced with the following simplest case.

- Start CB with blank workspace showing "Start here" page.
- Open "Console application" project wizard script in editor by [File|New|Project] dialog.
- Add "project.RemoveBuildTarget(0);" in SetupProject function just before "return true;".
- Save the script.
- Create a new project with the script by [File|New|Project].
- CB crashes.

Is that specific on my machine?  Thank you.
Title: Re: Project wizard crashes CB
Post by: oBFusCATed on May 21, 2020, 09:45:01 am
Generally a care should be taken to use the API correctly. It is a scripting API, but it is not too well protected.
I'll see what the problem is and prevent crashes, but probably your script is doing something it shouldn't do. Like removing a target that don't exists (this is a guess).
Title: Re: Project wizard crashes CB
Post by: KodamaDeveloped on May 21, 2020, 12:06:09 pm
Thanks for your reply.  I noticed the issue with my script at first, and it is reproduced in another than mine, which is "Console application" wizard script which is distributed with CB.  The simplest case I mentioned is supposed to remove "Debug" target because the script has had "Debug" and "Release" targets.  It works in some cases, crashes in the other cases (especially just after CB starts up).
Title: Re: Project wizard crashes CB
Post by: huycan on May 21, 2020, 01:43:49 pm
I did exactly the steps you mentioned above. And mine did not crash. I tested several times. No crash.

Anyway, from the documentation, the RemoveBuildTarget requires a string, not a numeric... So I suggest you should try
Code
project.RemoveBuildTarget(Wizard.GetDebugName());
instead.
Title: Re: Project wizard crashes CB
Post by: KodamaDeveloped on May 22, 2020, 12:41:49 am
Thanks for your try, so it looks the issue is probably specific on my machine, unfortunately (or fortunately?).  About the cbProject member RemoveBuildTarget function, from the documentation I think it has two overload versions, one of which takes int index as a parameter and the other takes const wxString &targetName.  I've experienced crashes with both versions.
Title: Re: Project wizard crashes CB
Post by: huycan on May 22, 2020, 06:22:37 am
Maybe you should try to put the project.RemoveBuildTarget here:
Code
// Debug build target
local target = project.GetBuildTarget(Wizard.GetDebugName());
if (!IsNull(target))
   //SetupTarget(target, true);
   project.RemoveBuildTarget(Wizard.GetDebugName());
}

I am just trying to help out, since my computer not crashing either way.
Title: Re: Project wizard crashes CB
Post by: oBFusCATed on May 22, 2020, 08:03:31 pm
I am just trying to help out, since my computer not crashing either way.
This is the beauty of memory corruptions :)