Author Topic: Distributing CB 20.03 compiled with debug configuration?  (Read 5628 times)

Offline KodamaDeveloped

  • Multiple posting newcomer
  • *
  • Posts: 16
Distributing CB 20.03 compiled with debug configuration?
« on: May 25, 2020, 11:36:59 am »
CB20.03, Win10/mingw64.

Isn't distributing CB 20.03 compiled with any debug configuration that's probably __WXDEBUG__?

After I upgraded to 20.03, if a tool assigned in [Tools+] menu outputs a message containing non-ascii characters to [Tool Output] window, CB complains with [wxWidgets Debug Alert] dialog as the following many times.
../../src/common/string.cpp(1176): assert "c < 0x80" failed in FromAscii(): Non-ASCII value passed to FromAscii().

I know the window cannot show non-ascii characters correctly because it uses wxString::FormAscii in its PipedProcessCtrl::SyncOutput function.  However, I don't like to see unnecessary dialogs popping up.

Thank you.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Distributing CB 20.03 compiled with debug configuration?
« Reply #1 on: May 25, 2020, 11:53:01 am »
wxAsserts are thing which should be reported and fixed. This is our first release with wx3.x, so we've decided to stick with them enabled.
The asserts dialog has a checkbox, so it is shown once per assert per session.

What are the exact steps to reproduce the problem?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline KodamaDeveloped

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Distributing CB 20.03 compiled with debug configuration?
« Reply #2 on: May 25, 2020, 02:28:13 pm »
Thank you, I believe I understand the situation.

To reproduce the problem...

- By [Tools+|Configure Tool] open [User-defined Tools] dialog.
- Click [New] to assign a new tool to [Tools+].
- Enter "TestApp" to both [Tool Name] and [Tools Menu Path] text boxes.
- Select "Tools Output Window" from [Output to] drop down list.
- Enter a file name of any console application which outputs other than ascii characters to stdout, to [Command line] text box.
- [OK] to close the dialog.
- Execute [Tools+|TestApp]

The TestApp could be the following for example.  It outputs a UTF-8 string.  The [wxWidgets Debug Alert] dialog pops up 21 times if you don't check the checkbox, because I think the string has 7 characters, all of which are 3 code length (3 bytes).

Code
#include <iostream>
int main()
{
    std::cout<<"\u3053\u3093\u306B\u3061\u306F\u4E16\u754C"<<std::endl;
    return 0;
}

I believe the problem is in PipedProcessCtrl::SyncOutput(plugins\contrib\ToolsPlus\PipedProcessCtrl.cpp:152, CB17.12).  wxString is constructed from a given string by wxString::FromAscii function which only handles ascii characters.  Although I've not understood why the function is called for each byte.

« Last Edit: May 25, 2020, 11:33:05 pm by KodamaDeveloped »

Offline KodamaDeveloped

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Distributing CB 20.03 compiled with debug configuration?
« Reply #3 on: May 25, 2020, 11:13:22 pm »
Although I've not understood why the function is called for each byte.

OK, wxString::FromAscii does check each byte... (src\common\string.cpp:1161, wxWidgets 3.1.0)

Code
wxString wxString::FromAscii(const char *ascii, size_t len)
{
    if (!ascii || len == 0)
       return wxEmptyString;

    wxString res;

    {
        wxStringInternalBuffer buf(res, len);
        wxStringCharType *dest = buf;

        for ( ; len > 0; --len )
        {
            unsigned char c = (unsigned char)*ascii++;
            wxASSERT_MSG( c < 0x80,
                          wxT("Non-ASCII value passed to FromAscii().") );

            *dest++ = static_cast<wxStringCharType>(c);
        }
    }

    return res;
}
« Last Edit: May 25, 2020, 11:41:50 pm by KodamaDeveloped »