Do I need to use the same "-std=xxxx" option to build wx library and application?

90 views
Skip to first unread message

asmwarrior

unread,
Oct 13, 2017, 9:17:41 PM10/13/17
to wx-u...@googlegroups.com

Hi, I use such command to build wx3.1

mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 USE_OPENGL=1 \
VENDOR=cb CXXFLAGS="-Wno-unused-local-typedefs -Wno-deprecated-declarations -fno-keep-inline-dllexport" >log-release.txt 2>&1

It's under mingw-build gcc 5.4 32bit compiler. Then I build the Code::Blocks source code and some of it's plugins, but which use
 "-std=gnu++11".

Finally, I see a crash happens in such code, this happens in 

void DirectoryParamsPanel::OnSearchDirTextEvent(wxCommandEvent &event)
{
    //m_pFindData->SetSearchPath(event.GetString());
    event.GetString();  // ****************Crash on this function call*************
    event.Skip();
}

If I comment out the GetString() function call, there is no crash. 
Some one also confirm that this crash happens in Code::Blocks build with wx git head,
It looks like this happens in a "release" build of wx library, debug version of wx library does not cause such crash. 
Also, the crash dose not happen in a wx2.8.12 based Code::Blocks.

The whole discussion are in the Code::Blocks's forum, where a crash call stack is also reported.
See here: http://forums.codeblocks.org/index.php/topic,22198.0.html

Any ideas?
Thanks.



Igor Korot

unread,
Oct 13, 2017, 10:23:44 PM10/13/17
to wx-u...@googlegroups.com
This option is part of CXXFLAGS which should be kept. Otherwise, IIUC, the binary generation will differ.

Please correct me if I'm wrong.

Thank you.


asmwarrior

unread,
Oct 13, 2017, 11:23:27 PM10/13/17
to wx-u...@googlegroups.com
On 10/14/2017 10:23 AM, Igor Korot wrote:
> This option is part of CXXFLAGS which should be kept. Otherwise, IIUC, the binary generation will differ.
>
> Please correct me if I'm wrong.
>
> Thank you.

Hi, thanks for the reply.

I just add the "-std=gnu++11" option:

mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 USE_OPENGL=1 VENDOR=cb CXXFLAGS="-Wno-unused-local-typedefs -Wno-deprecated-declarations -fno-keep-inline-dllexport -std=gnu++11" >log-release.txt 2>&1

to build the wx3.1 again, and then Code::Blocks source and plugins, but the bad news is the crash still happens.

Igor Korot

unread,
Oct 14, 2017, 12:11:22 AM10/14/17
to wx-u...@googlegroups.com
Hi,
Could you please post the backtrace at the time of the crash?

Thank you.


AsmWarrior

unread,
Oct 14, 2017, 12:59:09 AM10/14/17
to wx-users
Hi, the crash call stack is mentioned in my first post, I put in codeblocks' forum, thanks.

asmwarrior

unread,
Oct 14, 2017, 3:45:03 AM10/14/17
to wx-u...@googlegroups.com
On 10/14/2017 12:59 PM, AsmWarrior wrote:
> Hi, the crash call stack is mentioned in my first post, I put in codeblocks' forum, thanks.
>
If you look at the call stack in http://forums.codeblocks.org/index.php/topic,22198.0.html

You will see the main steps is that we first construct a wxComboBox, and then call wxComboBox::SetValue with
an empty wxString, and this trigger a wxCommandEvent event, thus the function defined in the event table is called.

EVT_TEXT_ENTER(controlIDs.Get(ControlIDs::idSearchDirPath), DirectoryParamsPanel::OnSearchDirTextEvent)

While, in the event handler, a crash happens in event.GetString(). This looks like the wxComboBox is not fully constructed?
All the above steps happen in the plugin loading stages.

Thanks.
Asmwarrior

asmwarrior

unread,
Oct 14, 2017, 9:52:07 AM10/14/17
to wx-u...@googlegroups.com
Oh, good news or bad news:
what is the bad thing is it looks like it is the same issue as the one
#17483 (wxDynamicCast segfault with mingw64 5.3.0 release build) – wxWidgets - https://trac.wxwidgets.org/ticket/17483


If I change the file: wxWidgets-3.1.0\src\common\event.cpp to add a "__attribute__((optimize("O0")))", like below


// ----------------------------------------------------------------------------
// wxCommandEvent
// ----------------------------------------------------------------------------

wxString __attribute__((optimize("O0"))) wxCommandEvent::GetString() const
{
// This is part of the hack retrieving the event string from the control
// itself only when/if it's really needed to avoid copying potentially huge
// strings coming from multiline text controls. For consistency we also do
// it for combo boxes, even though there are no real performance advantages
// in doing this for them.
if (m_eventType == wxEVT_TEXT && m_eventObject)
{
#if wxUSE_TEXTCTRL
wxTextCtrl *txt = wxDynamicCast(m_eventObject, wxTextCtrl);
if ( txt )
return txt->GetValue();
#endif // wxUSE_TEXTCTRL

#if wxUSE_COMBOBOX
wxComboBox* combo = wxDynamicCast(m_eventObject, wxComboBox);
if ( combo )
return combo->GetValue();
#endif // wxUSE_COMBOBOX
}

return m_cmdString;
}

Then, I don't have the crash issue in wx release library + Codeblocks.
So, it is a gcc bug?

Asmwarrior

Eran Ifrah

unread,
Oct 14, 2017, 9:58:47 AM10/14/17
to wx-u...@googlegroups.com
have you tried calling ChangeValue instead?
This should prevent the event from being fired

asmwarrior

unread,
Oct 14, 2017, 10:48:58 PM10/14/17
to wx-u...@googlegroups.com, Eran Ifrah
On 10/14/2017 9:58 PM, Eran Ifrah wrote:
> have you tried calling ChangeValue instead?
> This should prevent the event from being fired

Hi, Eran, thanks for the reply.
I just tried that using ChangeValue() can suppressing the firing the event.
But we do need the event, because a user entered value need to be saved.
As I mentioned in my previous post in this thread, it reason may come from GCC, because I encountered a similar issue one and a half year ago.
See: https://trac.wxwidgets.org/ticket/17483

Asmwarrior

AsmWarrior

unread,
Feb 24, 2018, 10:34:30 AM2/24/18
to wx-users
FYI: it looks like the crash issue I reported in this thread is gone by using a new GCC 7.2 compiler and wx3.1.1-rc.
Reply all
Reply to author
Forward
0 new messages