Discussion:
OSX - 3.0.1 - OPTION_VERBOSE and FindOptionByAnyName
___matthieu___
2014-06-25 07:56:01 UTC
Permalink
Hello,

I have a command line tool that crashes while parsing the arguments on the
command line.

The crash message is :
../src/common/cmdline.cpp(369): assert "Assert failure" failed in
FindOptionByAnyName(): Unknown option verbose

Call stack:
[00] wxAppConsoleBase::OnCmdLineParsed(wxCmdLineParser&)
[01] iCPApp::OnCmdLineParsed(wxCmdLineParser&) icpfind.cpp:7
[02] wxAppConsoleBase::OnInit()
[03] wxApp::CallOnInit()
[04] wxEntry(int&, wchar_t**)
[05] main icpfind.cpp:16
[06] start

The tool is icpfind from Hugin :

http://sourceforge.net/p/hugin/hugin/ci/default/tree/src/hugin1/icpfind/icpfind.cpp#l75

In OnCmdLineParsed(wxCmdLineParser &parser), a call is made to

wxAppConsole::OnCmdLineParsed(parser)

which in turn calls

parser.Found(OPTION_VERBOSE)

which then calls

wxCmdLineParserData::FindOptionByAnyName(const wxString& name)

The problem is that this method is searching for a "--verbose" argument
which is not here and thus calls wxFAIL_MSG, causing an error window to
appear where I do not think it should be.

I tried the same tool on linux (debian jessie x86_64, wxWidgets-3.0.1) and
did not have this behavior.

If you need more information, feel free to ask,

Cheers,

Matthieu
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-06-25 11:10:38 UTC
Permalink
Post by ___matthieu___
I have a command line tool that crashes while parsing the arguments on the
command line.
I wish we could find a way to explain better the difference between
crashes and an assertion failure. The former is (always) a bug. The latter
indicates the wrong use of wxWidgets API.
Post by ___matthieu___
http://sourceforge.net/p/hugin/hugin/ci/default/tree/src/hugin1/icpfind/icpfind.cpp#l75
In OnCmdLineParsed(wxCmdLineParser &parser), a call is made to
wxAppConsole::OnCmdLineParsed(parser)
which in turn calls
parser.Found(OPTION_VERBOSE)
which then calls
wxCmdLineParserData::FindOptionByAnyName(const wxString& name)
The problem is that this method is searching for a "--verbose" argument
which is not here and thus calls wxFAIL_MSG, causing an error window to
appear where I do not think it should be.
It should because you don't call wxAppConsoleBase::OnInitCmdLine() (which
adds "verbose" option) but you do call wxAppConsoleBase::OnCmdLineParsed().
You should either do the former or not do the latter, depending on whether
you want the verbose option (and any other standard command line options
possibly added in the future) to be handled.
Post by ___matthieu___
I tried the same tool on linux (debian jessie x86_64, wxWidgets-3.0.1) and
did not have this behavior.
Almost certainly because you're building with NDEBUG defined there, thus
disabling the asserts. The code is the same for all platforms and should
behave in the same way.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Matthieu DESILE
2014-06-29 09:14:10 UTC
Permalink
Post by Vadim Zeitlin
Post by ___matthieu___
I have a command line tool that crashes while parsing the arguments on the
command line.
I wish we could find a way to explain better the difference between
crashes and an assertion failure. The former is (always) a bug. The latter
indicates the wrong use of wxWidgets API.
my bad, I should have said an assertion was failing.
Post by Vadim Zeitlin
Post by ___matthieu___
http://sourceforge.net/p/hugin/hugin/ci/default/tree/src/hugin1/icpfind/icpfind.cpp#l75
In OnCmdLineParsed(wxCmdLineParser &parser), a call is made to
[...]
Post by Vadim Zeitlin
It should because you don't call wxAppConsoleBase::OnInitCmdLine() (which
adds "verbose" option) but you do call wxAppConsoleBase::OnCmdLineParsed().
You should either do the former or not do the latter, depending on whether
you want the verbose option (and any other standard command line options
possibly added in the future) to be handled.
ok, a developer sent me at the same time you were answering me a patch
doing exactly that (not calling the base method).

Thank you,

Matthieu
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Loading...