Author Topic: C::B runtime errors when WXWIN_COMPATIBILITY_2_4=0 or disable-compat24  (Read 16188 times)

Online stahta01

  • Lives here!
  • ****
  • Posts: 7785
    • My Best Post
FYI:

This thread is for troubleshooting crashes and errors when running Code::Blocks linked against wxWidgets 2.6 with WXWIN_COMPATIBILITY_2_4 set to 0. (WXWIN_COMPATIBILITY_2_4 is set in setup.h file.)

Tim S

Note: All known problems with WXWIN_COMPATIBILITY_2_4 set to 0 fixed by these two patches.
( Patches also work with wxWidgets 2.6 & wxWidgets 2.8 )

Patches to core Code::Blocks project and contrib Code::Blocks projects:
 [ Patch #1655 ] wxHIDE_READONLY patch for wxWidgets 2.7 Submitted By: stahta01
   https://developer.berlios.de/patch/?func=detailpatch&patch_id=1655&group_id=5358
 [ Patch #1661 ] wxCheckListBox patch for wxWidgets 2.7 Submitted By: stahta01
   https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=1661&group_id=5358
 [ Patch #1893 ] wxCheckListBox patch for wxWidgets 2.8 Submitted By: stahta01 found by wxLearner
   https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=1893&group_id=5358
« Last Edit: February 23, 2007, 01:02:10 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Online stahta01

  • Lives here!
  • ****
  • Posts: 7785
    • My Best Post
Re: C::B runtime errors when WXWIN_COMPATIBILITY_2_4=0
« Reply #1 on: November 26, 2006, 11:59:50 pm »
You were right, it seems that the crashes with wxWidgets 2.8.0 are in fact general crashes when compat24 is turned off... I'm seeing the same ones in wxWidgets 2.6.3p2 now, that I did with wxWidgets 2.8.0rc1 earlier:

Settings > Environments *crash*
Code
../src/generic/listctrl.cpp(3699): assert "wxAssertFailure" failed: invalid item index in SetItem
Settings > Editor *crash*
Code
../src/generic/listctrl.cpp(3699): assert "wxAssertFailure" failed: invalid item index in SetItem
Settings > Compiler and Debugger *crash*
Code
../src/common/list.cpp(326): assert "wxAssertFailure" failed: invalid index in wxListBase::Item
Settings > Global variables *crash*
Code
../src/mac/carbon/choice.cpp(217): assert "wxAssertFailure" failed: wxChoice::GetString(): invalid index

So it seems that debugging/fixing Code::Blocks with this compat setting turned off in wxWidgets 2.6 is a good idea to start with, as it is both good now and will also help running with wxWidgets 2.8 later ?
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: C::B runtime errors when WXWIN_COMPATIBILITY_2_4=0
« Reply #2 on: November 27, 2006, 12:00:38 am »
WXWIN_COMPATIBILITY_2_4 set to 0. (WXWIN_COMPATIBILITY_2_4 is set in setup.h file.)

If you are building wxWidgets with autotools (./configure),
this instead corresponds to the --disable-compat24 flag...

Online stahta01

  • Lives here!
  • ****
  • Posts: 7785
    • My Best Post
Re: C::B runtime errors when WXWIN_COMPATIBILITY_2_4=0
« Reply #3 on: November 27, 2006, 12:09:56 am »
Settings > Environments *crash* issue

File: src/src/environmentsettingsdlg.cpp

replaced line
    wxCheckListBox* clb = XRCCTRL(*this, "chkDialogs", wxCheckListBox);
with lines
    int xrcId = wxXmlResource::GetXRCID(wxT("chkDialogs"));
    cbAssert(xrcId);
    wxWindow* aWindow = (*this).FindWindow(xrcId);
    cbAssert(aWindow != NULL);
    wxCheckListBox* clb = (wxStaticCast(aWindow, wxCheckListBox));
    cbAssert(clb != NULL);

The above is valid under windows, look in wx/xrc/xmlres.h to verify this substitution.
Note: under windows (*this).FindWindow(xrcId); is returning null.

See common/window.cpp for FindWindow code.
See wx/msw/window.h for wxWindowList
See wx/hash.h for WX_DECLARE_HASH

I am thinking it is a Hash table related error at this time, I am trying to compile wx26 with wxUSE_STL to help to confirm or deny my current theory. I am trying to add STLPort to minGW 3.4.5; downloading it from orge3d site. (Did NOT need STLPort to compile wx2.6 with wxUSE_STL=1, but C::B does NOT like wxUSE_STL=1)

Tim S
« Last Edit: November 27, 2006, 11:21:52 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
« Last Edit: November 27, 2006, 11:11:32 am by afb »

Online stahta01

  • Lives here!
  • ****
  • Posts: 7785
    • My Best Post
Re: C::B runtime errors when WXWIN_COMPATIBILITY_2_4=0 or disable-compat24
« Reply #5 on: November 27, 2006, 11:31:46 am »
I think some of these were showing up as failed assertions before, well worth looking into:
http://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=1538&group_id=5358
http://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=1539&group_id=5358


This one looks useful.

[ Patch #1538 ] Assert failure fixes
http://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=1538&group_id=5358

But, the other one does not apply to this problem, so most likely not useful. Also, it should not be used with this pointers, therefore it could cause more issues. I already tried all the types of wx casts I could find, the problem is in the findWindow not the cast. See file wx/object.h for wxDynamicCastThis as the correct way to cast this.

Correction: The object being casted is not an this object, so it should be safe, but it still does NOT apply to this exact bug.

Note: I am double checking by redoing the test with debug and WXWIN_COMPATIBILITY_2_4=1.
Ran my test code with debug and WXWIN_COMPATIBILITY_2_4=1 and had no crashes or assertions.

Tim S

« Last Edit: November 27, 2006, 12:18:10 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: C::B runtime errors when WXWIN_COMPATIBILITY_2_4=0 or disable-compat24
« Reply #6 on: November 27, 2006, 11:58:43 am »
But, the other one does not apply to this problem, so most likely not useful.

Maybe not, but getting rid of the failed assertions looked like a worthy side-effect of this bughunt.

Online stahta01

  • Lives here!
  • ****
  • Posts: 7785
    • My Best Post
Re: C::B runtime errors when WXWIN_COMPATIBILITY_2_4=0 or disable-compat24
« Reply #7 on: November 27, 2006, 12:14:56 pm »
But, the other one does not apply to this problem, so most likely not useful.

Maybe not, but getting rid of the failed assertions looked like a worthy side-effect of this bughunt.

But, the one patch is replacing a static cast with a dynamic cast, so its needs to be verified that you are not just moving the errors from compile/link time to runtime. Note, that is why he says to check for a valid object before doing the Macro. I am far from being able to say the patch is safe or not safe, but at current time don't see the need for it. I think the assertion should be failing in this case, not that it should NOT be.

Tim S
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: C::B runtime errors when WXWIN_COMPATIBILITY_2_4=0 or disable-compat24
« Reply #8 on: November 27, 2006, 12:17:11 pm »
As long as it runs without assertions for normal usage, it's all OK...
I didn't mean for the patch applied as-is, as it is rather old by now.

Online stahta01

  • Lives here!
  • ****
  • Posts: 7785
    • My Best Post
Re: C::B runtime errors when WXWIN_COMPATIBILITY_2_4=0 or disable-compat24
« Reply #9 on: November 27, 2006, 12:23:55 pm »
As long as it runs without assertions for normal usage, it's all OK...
I didn't mean for the patch applied as-is, as it is rather old by now.

My test code even works OK with debug and WXWIN_COMPATIBILITY_2_4=1.
The problem is findWindow in my opinion; I am going to work on a small test case of the problem.
I am starting with samples\xrc under 2.6.3 as a starting point. I hope to be able to reproduce the issue for the wxWidgets people to look at.

Tim S
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Online stahta01

  • Lives here!
  • ****
  • Posts: 7785
    • My Best Post
Re: C::B runtime errors when WXWIN_COMPATIBILITY_2_4=0 or disable-compat24
« Reply #10 on: November 27, 2006, 01:38:31 pm »
Found cause

env_settings.xrc inside resources.zip is using class="wxCheckList" it should use class="wxCheckListBox"

Edit: I have confirmed it fixes the issue under 2.6, trying 2.8 now.
Fixed most of the problems under 2.8rc1+patches also.

Patch: [ Patch #1661 ] wxCheckListBox patch for wxWidgets 2.7 https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=1661&group_id=5358

Tim S
« Last Edit: November 27, 2006, 04:33:06 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Online stahta01

  • Lives here!
  • ****
  • Posts: 7785
    • My Best Post
Re: C::B runtime errors when WXWIN_COMPATIBILITY_2_4=0 or disable-compat24
« Reply #11 on: November 27, 2006, 11:28:24 pm »
Work on 2.8 with WXWIN_COMPATIBILITY_2_4=0 is proceeding in this thread
Patches to compile and link C::B against wxWidgets 2.8.0
http://forums.codeblocks.org/index.php?topic=4495.0

Tim S
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

wxLearner

  • Guest
Re: C::B runtime errors when WXWIN_COMPATIBILITY_2_4=0 or disable-compat24
« Reply #12 on: February 20, 2007, 02:23:31 pm »
env_settings.xrc inside resources.zip is using class="wxCheckList" it should use class="wxCheckListBox"
The project dependencies dialog also crashes with wx 2.8.0 due to the same kind of issue:
project_deps.xrc in manager_resources.zip (src/sdk/resources/project_deps.xrc in svn) is using "wxCheckList" instead of "wxCheckListBox".

Online stahta01

  • Lives here!
  • ****
  • Posts: 7785
    • My Best Post
Re: C::B runtime errors when WXWIN_COMPATIBILITY_2_4=0 or disable-compat24
« Reply #13 on: February 20, 2007, 03:22:39 pm »
env_settings.xrc inside resources.zip is using class="wxCheckList" it should use class="wxCheckListBox"
The project dependencies dialog also crashes with wx 2.8.0 due to the same kind of issue:
project_deps.xrc in manager_resources.zip (src/sdk/resources/project_deps.xrc in svn) is using "wxCheckList" instead of "wxCheckListBox".

Patch:

Code
Index: src/sdk/resources/project_deps.xrc
===================================================================
--- src/sdk/resources/project_deps.xrc (revision 3627)
+++ src/sdk/resources/project_deps.xrc (working copy)
@@ -28,7 +28,7 @@
         <border>8</border>
       </object>
       <object class="sizeritem">
-        <object class="wxCheckList" name="lstDeps">
+        <object class="wxCheckListBox" name="lstDeps">
           <content/>
         </object>
         <option>1</option>

I have tried to submit this patch to BerliOS, but I can NOT get to the page for submitting it.
Tim S
« Last Edit: February 20, 2007, 03:43:09 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org