Author Topic: crash when I try to open a wxsmith file under C::B against wx 3.3.1  (Read 2860 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6139
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
It looks like the C::B try to read some string values to "reconstruct" the prop grid when reading the wxs file.

But the "string value" maybe empty or not correct, so wx just report the assert.

My guess is that the issue is inside the wxWidgets' library code, not in the C::B's source code.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1817
This method, defined in wxscolourproperty.cpp:152
Code
    wxString wxsMyColourPropertyClass::ValueToString( wxVariant& value,  int argFlags ) const
does not override in wx >= 3.3.0 because the second parameter is no longer an integer, see the documentation.

EDIT: Adding "override" to the declaration would have uncovered this long ago.
« Last Edit: Yesterday at 05:14:10 pm by Miguel Gimenez »

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1817
Try this file (rename as cpp). It may need some adjustment to compile on wx3.3.

Offline gd_on

  • Lives here!
  • ****
  • Posts: 837
Not extensively tested, but it looks OK : wxs files are opened without crash.
Thanks
« Last Edit: Today at 09:26:50 am by gd_on »
Windows 11 64 bits (25H2), svn C::B (last version or almost!), wxWidgets 3.3.1, Msys2 Compilers 15.2.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6139
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Not extensivety tested, but it looks OK : wxs files are opened without crash.
Thanks

Strange, I just replaced my local the file: wxscolourproperty.cpp, but the result C::B still crash with the same issue.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6139
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
I think I have reported the same issue here in 2025-09, see this post:

Re: code::blocks hangs at startup

So, this issue lasts for a long time.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6139
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Not extensivety tested, but it looks OK : wxs files are opened without crash.
Thanks

I try to build a debug version of wx 3.3.1 library, and later build C::B against this library.

When I try to run the debugging, I see this:

Code
Active debugger config: GDB/CDB debugger:Default
Selecting target:
src
Adding source dir: F:\code\codeblocks-src\codeblocks_sfmirror\src\
Adding source dir: F:\code\codeblocks-src\codeblocks_sfmirror\src\
Adding file: F:\code\codeblocks-src\codeblocks_sfmirror\src\devel33_64\codeblocks.exe
Changing directory to: F:/code/codeblocks-src/codeblocks_sfmirror/src/devel33_64
Set variable: PATH=.;F:\code\wxWidgets-3.3.1\lib\gcc_dll"";F:\code\codeblocks-src\codeblocks_sfmirror\src\devel33_64;F:\code\codeblocks-src\codeblocks_sfmirror\src\exchndl\win64\lib;...

Then, it said the wx dll can't be find, so the debugee C::B can't started.

But if you looked at this:

Code
F:\code\wxWidgets-3.3.1\lib\gcc_dll""

You see the trailing quotes, this quotes come from some global compiler variable those values are "".
It works OK when in compiling, I see such things when compiling:

Code
[100.0%] g++.exe -shared  -Wl,--out-implib=devel33_64\libcodeblocks.a -Wl,--dll 
-LF:\code\wxWidgets-3.3.1\lib\gcc_dll""
-Ldevel33_64

Now, here is the crash call stack, I put it in the txt file in attachment.


If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6139
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Code
#if WXWIN_COMPATIBILITY_3_2
// By call to obsolete function we want to check if user-overriden function is still in use
wxString wxPGProperty::ValueToStringWithCheck(wxVariant& variant, wxPGPropValFormatFlags flags) const
{
    m_oldValueToStringCalled = false;
    wxString res = ValueToString(variant, static_cast<int>(flags));
    if ( m_oldValueToStringCalled )
    {
        // Our own function was called - this implies that call was forwarded to the new overriding
        // function and there is no need to call it explicitly.
    }
    else
    {   // User-overriden obsolete function was called
        wxFAIL_MSG(wxString::Format("in %s use ValueToString with 'flags' argument as wxPGPropValFormatFlags", GetClassInfo()->GetClassName()));
    }
    return res;
}
#endif // WXWIN_COMPATIBILITY_3_2

In the call stack frame 2, this function always cause assert, do you see this? I have update comments in github issue: https://github.com/wxWidgets/wxWidgets/issues/26108#issuecomment-3803542263
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.