Author Topic: Threadsearch plugin cause crash when initilized (wx3.1,C::B svn head)  (Read 1063 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 4982
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
I see the thread search plugin cause crash when initilized, here is the line it crashed:

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

Here is the call stack:
Code: [Select]
[debug]Thread 1 received signal SIGSEGV, Segmentation fault.
[debug]0x6885d39d in wxCommandEvent::GetString() const () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]>>>>>>cb_gdb:

In wxCommandEvent::GetString() const () (D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll)

[debug]> bt 30
[debug]#0  0x6885d39d in wxCommandEvent::GetString() const () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#1  0x0d221da7 in DirectoryParamsPanel::OnSearchDirTextEvent (this=0xa41f070, event=...) at D:\code\cb\cb_sf_git\clean-trunk-for-commit\src\plugins\contrib\ThreadSearch\DirectoryParamsPanel.cpp:98
[debug]#2  0x68702eb2 in wxAppConsoleBase::HandleEvent(wxEvtHandler*, void (wxEvtHandler::*)(wxEvent&), wxEvent&) const () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#3  0x68703217 in wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#4  0x6885bc80 in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#5  0x6885bd6a in wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#6  0x6885c549 in wxEvtHandler::TryHereOnly(wxEvent&) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#7  0x6885c5ba in wxEvtHandler::ProcessEventLocally(wxEvent&) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#8  0x6885c615 in wxEvtHandler::ProcessEvent(wxEvent&) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#9  0x68b24c8a in wxWindowBase::TryAfter(wxEvent&) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#10 0x6885dff2 in wxEvtHandler::SafelyProcessEvent(wxEvent&) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#11 0x68b0cd18 in wxTextEntryBase::SendTextUpdatedEvent(wxWindow*) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#12 0x68b0cf57 in wxTextEntryBase::DoSetValue(wxString const&, int) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#13 0x68975ce1 in wxComboBox::SetValue(wxString const&) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#14 0x0d222839 in DirectoryParamsPanel::SetSearchDirPath (this=0xa41f070, sDirPath=L"") at D:\code\cb\cb_sf_git\clean-trunk-for-commit\src\plugins\contrib\ThreadSearch\DirectoryParamsPanel.cpp:182
[debug]#15 0x0d23b534 in ThreadSearchView::set_properties (this=0xa462588) at D:\code\cb\cb_sf_git\clean-trunk-for-commit\src\plugins\contrib\ThreadSearch\ThreadSearchView.cpp:376
[debug]#16 0x0d2394c5 in ThreadSearchView::ThreadSearchView (this=0xa462588, threadSearchPlugin=...) at D:\code\cb\cb_sf_git\clean-trunk-for-commit\src\plugins\contrib\ThreadSearch\ThreadSearchView.cpp:95
[debug]#17 0x0d226249 in ThreadSearch::OnAttach (this=0xa452778) at D:\code\cb\cb_sf_git\clean-trunk-for-commit\src\plugins\contrib\ThreadSearch\ThreadSearch.cpp:183
[debug]#18 0x01700408 in cbPlugin::Attach (this=0xa452778) at D:\code\cb\cb_sf_git\clean-trunk-for-commit\src\sdk\cbplugin.cpp:73
[debug]#19 0x0179c7e3 in PluginManager::AttachPlugin (this=0xa20ea38, plugin=0xa452778, ignoreSafeMode=false) at D:\code\cb\cb_sf_git\clean-trunk-for-commit\src\sdk\pluginmanager.cpp:195
[debug]#20 0x017a28d2 in PluginManager::LoadAllPlugins (this=0xa20ea38) at D:\code\cb\cb_sf_git\clean-trunk-for-commit\src\sdk\pluginmanager.cpp:1104
[debug]#21 0x0045370c in MainFrame::ScanForPlugins (this=0x6a00648) at D:\code\cb\cb_sf_git\clean-trunk-for-commit\src\src\main.cpp:1209
[debug]#22 0x0044e9b7 in MainFrame::MainFrame (this=0x6a00648, parent=0x0) at D:\code\cb\cb_sf_git\clean-trunk-for-commit\src\src\main.cpp:633
[debug]#23 0x004029b3 in CodeBlocksApp::InitFrame (this=0x6778248) at D:\code\cb\cb_sf_git\clean-trunk-for-commit\src\src\app.cpp:489
[debug]#24 0x00403f47 in CodeBlocksApp::OnInit (this=0x6778248) at D:\code\cb\cb_sf_git\clean-trunk-for-commit\src\src\app.cpp:697
[debug]#25 0x004c93a6 in wxAppConsoleBase::CallOnInit (this=0x6778248) at D:\code\wxWidgets-3.1.0\include\wx\app.h:93
[debug]#26 0x687847d2 in wxEntryReal(int&, wchar_t**) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#27 0x004021af in WinMain@16 (hInstance=0x400000, hPrevInstance=0x0, nCmdShow=10) at D:\code\cb\cb_sf_git\clean-trunk-for-commit\src\src\app.cpp:322
[debug]#28 0x004f73ad in main ()
[debug]>>>>>>cb_gdb:
[debug]> frame 1
[debug]#1  0x0d221da7 in DirectoryParamsPanel::OnSearchDirTextEvent (this=0xa41f070, event=...) at D:\code\cb\cb_sf_git\clean-trunk-for-commit\src\plugins\contrib\ThreadSearch\DirectoryParamsPanel.cpp:98
[debug]D:\code\cb\cb_sf_git\clean-trunk-for-commit\src\plugins\contrib\ThreadSearch\DirectoryParamsPanel.cpp:98:4038:beg:0xd221da7
[debug]>>>>>>cb_gdb:


It sounds like the passed wxCommandEvent object has some problems, it just crashed when the event.GetString() function is called.

You can see it is in the initialization stage, because it crashed in the ThreadSearchView::ThreadSearchView() function call.
Code: [Select]
...
[debug]#14 0x0d222839 in DirectoryParamsPanel::SetSearchDirPath (this=0xa41f070, sDirPath=L"") at D:\code\cb\cb_sf_git\clean-trunk-for-commit\src\plugins\contrib\ThreadSearch\DirectoryParamsPanel.cpp:182
[debug]#15 0x0d23b534 in ThreadSearchView::set_properties (this=0xa462588) at D:\code\cb\cb_sf_git\clean-trunk-for-commit\src\plugins\contrib\ThreadSearch\ThreadSearchView.cpp:376
[debug]#16 0x0d2394c5 in ThreadSearchView::ThreadSearchView (this=0xa462588, threadSearchPlugin=...) at D:\code\cb\cb_sf_git\clean-trunk-for-commit\src\plugins\contrib\ThreadSearch\ThreadSearchView.cpp:95
[debug]#17 0x0d226249 in ThreadSearch::OnAttach (this=0xa452778) at D:\code\cb\cb_sf_git\clean-trunk-for-commit\src\plugins\contrib\ThreadSearch\ThreadSearch.cpp:183
...


The bad thing is I can not see the event under gdb
Code: [Select]
[debug]> p event
[debug]$1 = (wxCommandEvent &) @0x28e3e4: <incomplete type>
[debug]>>>>>>cb_gdb:

$1 = (wxCommandEvent &) @0x28e3e4: <incomplete type>

I'm using Win7 64bit, mingw-build gcc 5.4 32bit compiler, wx3.1.

Thanks.
« Last Edit: October 14, 2017, 10:50:48 am by ollydbg »
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.

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10357
Re: Threadsearch plugin cause crashe when initilized (wx3.1,C::B svn head)
« Reply #1 on: October 12, 2017, 09:27:50 am »
Are you sure everything is built with the same compiler? And you're using the correct wx libraries and headers?
<debugger plugin maintainer>
(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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 4982
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Threadsearch plugin cause crashe when initilized (wx3.1,C::B svn head)
« Reply #2 on: October 12, 2017, 12:12:12 pm »
Are you sure everything is built with the same compiler? And you're using the correct wx libraries and headers?
Yes, I have used the same compiler to rebuild the wx library and c::b yesterday, and I see the same issue as before.
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: 4982
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Threadsearch plugin cause crashe when initilized (wx3.1,C::B svn head)
« Reply #3 on: October 13, 2017, 04:49:31 pm »
Oh, is it caused by the different building options when I build C::B and wx?

I have used such command to build wx:
Code: [Select]
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

While I see when building Codeblocks_w31.cbp, I see it use "-std=gnu++11", while when I build threadsearch plugin, I see it also use "-std=gnu++11".

Do I need to add the "-std=gnu++11" to build the wx library?
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 BlueHazzard

  • Lives here!
  • ****
  • Posts: 1541
Re: Threadsearch plugin cause crashe when initilized (wx3.1,C::B svn head)
« Reply #4 on: October 13, 2017, 05:05:51 pm »
i can not reproduce this with
wxWidgets git hash: c51dd81db6da3aa2fc853b452ca2500776b473ed debug build
Codeblocks trunk
gcc 5.1
win7

i can reproduce a crash with release builds, but i can not debug where it comes from because no stack trace. Only
Code: [Select]
In wxCommandEvent::GetString() const () (wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_custom.dll)
and a lot ???

Quote
Do I need to add the "-std=gnu++11" to build the wx library?
i have also not enabled c++11 for wx builds
« Last Edit: October 13, 2017, 05:07:49 pm by BlueHazzard »

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 4982
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Threadsearch plugin cause crashe when initilized (wx3.1,C::B svn head)
« Reply #5 on: October 14, 2017, 03:02:33 am »
Hi, BlueHazzard, thanks for the tests, so this happens only in release version of wx(either in wx3.1 or wx git head), I will ask the question to wx maillist.

EDIT: posted here: https://groups.google.com/d/msg/wx-users/LUxm6fUhirk/FJRFNIt6AAAJ
« Last Edit: October 14, 2017, 03:20:07 am by ollydbg »
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: 4982
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Threadsearch plugin cause crash when initilized (wx3.1,C::B svn head)
« Reply #6 on: October 14, 2017, 10:55:13 am »
I just build a debug version of wx3.1 with the following command: (note I have -std=gnu++11)
Code: [Select]
mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=debug UNICODE=1 USE_OPENGL=1 VENDOR=cb CXXFLAGS="-Wno-unused-local-typedefs -Wno-deprecated-declarations -fno-keep-inline-dllexport -std=gnu++11" >log-debug-cxx11.txt 2>&1

And then I just rebuild the C::B against this wx3.1, and I don't see the crash. While, if I add the -std=gnu++11 option to build a release version of wx3.1, the crash still happens.

Guess: Do I need to add the option "-fno-keep-inline-dllexport" to build the C::B or the plugins?  That's was too complex if both the wx library and C::B need the exact same build option. :(

EDIT: please note that my wx3.1 source was already applied a patch to avoid a crash (in wxWidgets-3.1.0\include\wx\rtti.h, see #17483 (wxDynamicCast segfault with mingw64 5.3.0 release build) wxWidgets):
Code: [Select]
    bool IsKindOf(const wxClassInfo *info) const
    {
        if ( info == this )
            return true;

        if ( m_baseInfo1 )
        {
            if ( m_baseInfo1->IsKindOf(info) )
                return true;
        }

        if ( m_baseInfo2 )
        {
            if ( m_baseInfo2->IsKindOf(info) )
                return true;
        }

        return false;
    }
« Last Edit: October 14, 2017, 11:00:10 am by ollydbg »
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: 4982
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Threadsearch plugin cause crash when initilized (wx3.1,C::B svn head)
« Reply #7 on: October 14, 2017, 03:57:15 pm »
Oh my god, it looks like I meet a similar gcc bug, I just find the cause of this bug, see here:

in wxWidgets's ticket #17483 and https://groups.google.com/d/msg/wx-users/LUxm6fUhirk/GOX_obajAAAJ in wx-user maillist.
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 BlueHazzard

  • Lives here!
  • ****
  • Posts: 1541
Re: Threadsearch plugin cause crash when initilized (wx3.1,C::B svn head)
« Reply #8 on: October 14, 2017, 05:44:30 pm »
So if you apply this optimization patch the crash goes away? So this should be reported to gcc?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5969
    • My Best Post
Re: Threadsearch plugin cause crash when initilized (wx3.1,C::B svn head)
« Reply #9 on: October 14, 2017, 07:50:12 pm »
So if you apply this optimization patch the crash goes away? So this should be reported to gcc?

The second one I would vote no, because I think the GCC crew would rightly say it is a wxWidgets bug.

The first one, I have no idea what the cause is; but, I would guess the right solution is to disable optimization.
Note: That might also fix the second bug. IIRC, someone found the right optimization to disable already.
Might that optimization only be needed on the second bug on wxWidgets's code.
Since, it is not in a header file.

I would try "-fno-delete-null-pointer-checks" in building wxWidgets and see if the second problem goes away.

Tim S.

 
« Last Edit: October 14, 2017, 07:54:42 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10357
Re: Threadsearch plugin cause crash when initilized (wx3.1,C::B svn head)
« Reply #10 on: October 14, 2017, 08:01:57 pm »
If an valid optimisation breaks users code then the code is broken and must be fixed.
Disabling specific optimisations is only a short term workaround!
<debugger plugin maintainer>
(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 stahta01

  • Lives here!
  • ****
  • Posts: 5969
    • My Best Post
Re: Threadsearch plugin cause crash when initilized (wx3.1,C::B svn head)
« Reply #11 on: October 14, 2017, 09:32:46 pm »
If an valid optimisation breaks users code then the code is broken and must be fixed.
Disabling specific optimisations is only a short term workaround!

Re-writing wxWidgets to use C++ correctly is a very big job; it will likely take a while! As in years.
Adding the option to see if it works is much faster.

Do you wish to port CB to no longer use the wxWidgets backend?
Or, switch to using wxWidgets for STL build? (No idea if this will fix the issue; but, it has a slight chance)
Edit1: I forgot this bug is wxWidgets RTTI not wxWidgets STL class bug.
Or, try disabling what ever compiler/linker option is causing this bug?
The only other option is finding another solution or ignoring the bug.

Tim S.
« Last Edit: October 14, 2017, 09:35:13 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 4982
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Threadsearch plugin cause crash when initilized (wx3.1,C::B svn head)
« Reply #12 on: October 14, 2017, 11:26:56 pm »
So if you apply this optimization patch the crash goes away? So this should be reported to gcc?
yes and yes, I have already report to gcc bugzilla. see the links of my previous post.

edit: it is https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71867
« Last Edit: October 14, 2017, 11:31:56 pm by ollydbg »
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: 4982
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Threadsearch plugin cause crash when initilized (wx3.1,C::B svn head)
« Reply #13 on: October 14, 2017, 11:35:10 pm »
I would try "-fno-delete-null-pointer-checks" in building wxWidgets and see if the second problem goes away.


I already try this years ago, but the crash still exists.
see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71867
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 blauzahn

  • Multiple posting newcomer
  • *
  • Posts: 70
Re: Threadsearch plugin cause crash when initilized (wx3.1,C::B svn head)
« Reply #14 on: October 23, 2017, 09:20:44 pm »

To me, that looks like undefined behaviour:

Code: [Select]
void ThreadSearch::SetManagerType(ThreadSearchViewManagerBase::eManagerTypes mgrType)
{
    // Is type different from current one ?
    if ( mgrType != m_pViewManager->GetManagerType() )
    {
        // Get show state and destroy current view manager.
        bool show(true);
        if ( m_pViewManager != NULL )          // <---------------- UB
        {
            show = m_pViewManager->IsViewShown();
            m_pViewManager->RemoveViewFromManager();
            delete m_pViewManager;
        }

        // Create and show new view manager.
        m_pViewManager = ThreadSearchViewManagerBase::BuildThreadSearchViewManagerBase(m_pThreadSearchView, true, mgrType);
        m_pViewManager->ShowView(show);
    }
}

A null-pointer check AFTER having dereferenced m_pViewManager.
If memory serves me, this in combination with "-fno-delete-null-pointer-checks"
led to bugs like heartbleed.

obfuscated:
Quote
If an valid optimisation breaks users code then the code is broken and must be fixed.
Disabling specific optimisations is only a short term workaround!
I agree with that.

Cheers!

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10357
Re: Threadsearch plugin cause crash when initilized (wx3.1,C::B svn head)
« Reply #15 on: October 24, 2017, 12:37:46 am »
To me, that looks like undefined behaviour:
I'll need a quote from the standard where they've made this undefined behaviour.
Newer compilers might delete the check, but this doesn't make the check undefined behaviour (if you find the quote from the standard, then I'll admit my mistake)!


A null-pointer check AFTER having dereferenced m_pViewManager.
If memory serves me, this in combination with "-fno-delete-null-pointer-checks"
led to bugs like heartbleed.
How is this related, to Code::Blocks where we don't care at all about security.
And it seems you're wrong, because by the looks of it (I have no time to read the whole report) heartbleed is just a logic error and nothing related to compilers or UB.

And finally how is this thing related to the original problem?
<debugger plugin maintainer>
(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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 4982
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Threadsearch plugin cause crash when initilized (wx3.1,C::B svn head)
« Reply #16 on: October 24, 2017, 01:59:17 am »

And finally how is this thing related to the original problem?

I agree, it is not related.
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: 4982
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Threadsearch plugin cause crash when initilized (wx3.1,C::B svn head)
« Reply #17 on: October 24, 2017, 04:34:05 pm »
I see another strange issue, the combobox's content can't be saved after the dialog closed. When I close the option, and I see the combobox becomes "*.*" again. Any one can reproduce this issue? I'm on 32bit C::B build against wx3.1 under windows 7.

See image shot below:
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 danselmi

  • Developer
  • Almost regular
  • *****
  • Posts: 199
Re: Threadsearch plugin cause crash when initilized (wx3.1,C::B svn head)
« Reply #18 on: October 24, 2017, 09:56:14 pm »

And finally how is this thing related to the original problem?

I agree, it is not related.

It is not undefined behaviour. But the check is definitely too late. 4 lines above the m_pViewManager was already dereferenced.

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10357
Re: Threadsearch plugin cause crash when initilized (wx3.1,C::B svn head)
« Reply #19 on: October 25, 2017, 12:04:39 am »
@ollydbg: Changing the value in the dialog works fine for me on linux with 3.1.1
<debugger plugin maintainer>
(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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 4982
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Threadsearch plugin cause crash when initilized (wx3.1,C::B svn head)
« Reply #20 on: October 28, 2017, 10:16:21 am »
@ollydbg: Changing the value in the dialog works fine for me on linux with 3.1.1
I debugged this issue under Windows7 for a while, and it is a bug.

For example, if I set the mask as "*.abc", which means I only want to search the files which has the file name pattern as "*.abc", I can see this value is correctly saved to the conf file.

Code: [Select]
<MASK>
<str>
<![CDATA[*.abc]]>
</str>
</MASK>

While, when I close the CB, and restart again, I see that the "*.abc" is correctly loaded and set the the value "ThreadSearchFindData". But the bad thing happens is when the combobox constructed, it was set the a default value "*.*", see the code below:
Code: [Select]
DirectoryParamsPanel::DirectoryParamsPanel(ThreadSearchFindData *findData, wxWindow* parent, int id, const wxPoint& pos,
                                           const wxSize& size, long WXUNUSED(style)):
    wxPanel(parent, id, pos, size, wxTAB_TRAVERSAL),
    m_pFindData(findData)
{
    const wxString choices[] = {};

    // begin wxGlade: DirectoryParamsPanel::DirectoryParamsPanel
    m_pSearchDirPath = new wxComboBox(this, controlIDs.Get(ControlIDs::idSearchDirPath), wxEmptyString,
                                      wxDefaultPosition, wxDefaultSize, 0, choices, wxCB_DROPDOWN|wxTE_PROCESS_ENTER);
    m_pBtnSelectDir = new wxButton(this, controlIDs.Get(ControlIDs::idBtnDirSelectClick), _("..."));
    m_pChkSearchDirRecursively = new wxCheckBox(this, controlIDs.Get(ControlIDs::idChkSearchDirRecurse), _("Recurse"));
    m_pChkSearchDirHiddenFiles = new wxCheckBox(this, controlIDs.Get(ControlIDs::idChkSearchDirHidden), _("Hidden"));
    m_pMask = new wxComboBox(this, controlIDs.Get(ControlIDs::idSearchMask), wxT("*.*"),
                             wxDefaultPosition, wxDefaultSize, 0, choices, wxCB_DROPDOWN|wxTE_PROCESS_ENTER);

    set_properties();
    do_layout();
    // end wxGlade
}

I see the ThreadSearchFindData will be updated in a event handler:
Code: [Select]
[debug]> bt 30
[debug]#0  ThreadSearchFindData::SetSearchMask (this=0xa93270c, searchMask=L"*.*") at D:\code\cb\cb_sf_git\trunk\src\plugins\contrib\ThreadSearch\ThreadSearchFindData.h:53
[debug]#1  0x0d331e37 in DirectoryParamsPanel::OnSearchMaskTextEvent (this=0xa976340, event=...) at D:\code\cb\cb_sf_git\trunk\src\plugins\contrib\ThreadSearch\DirectoryParamsPanel.cpp:103
[debug]#2  0x68702ec2 in wxAppConsoleBase::HandleEvent(wxEvtHandler*, void (wxEvtHandler::*)(wxEvent&), wxEvent&) const () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#3  0x68703327 in wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#4  0x6885a3c0 in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#5  0x68858f6a in wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#6  0x6885a709 in wxEvtHandler::TryHereOnly(wxEvent&) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#7  0x6885a61a in wxEvtHandler::ProcessEventLocally(wxEvent&) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#8  0x6885a505 in wxEvtHandler::ProcessEvent(wxEvent&) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#9  0x68b1d5ea in wxWindowBase::TryAfter(wxEvent&) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#10 0x6885a752 in wxEvtHandler::SafelyProcessEvent(wxEvent&) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#11 0x68973d5c in wxComboBox::MSWCommand(unsigned int, unsigned short) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#12 0x6893635b in wxWindow::HandleCommand(unsigned short, unsigned short, HWND__*) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#13 0x6893fdc9 in wxWindow::MSWHandleMessage(long*, unsigned int, unsigned int, long) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#14 0x68930a20 in wxWindow::MSWWindowProc(unsigned int, unsigned int, long) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#15 0x68938843 in wxWndProc(HWND__*, unsigned int, unsigned int, long)@16 () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#16 0x75bc62fa in gapfnScSendMessage () from C:\windows\syswow64\user32.dll
[debug]#17 0x001308dc in ?? ()
[debug]#18 0x00000111 in ?? ()
[debug]#19 0x00050484 in ?? ()
[debug]#20 0x000a07fa in ?? ()
[debug]#21 0x689387d0 in wxWindow::SubclassWin(HWND__*) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#22 0x75bc6d3a in USER32!GetThreadDesktop () from C:\windows\syswow64\user32.dll
[debug]#23 0x689387d0 in wxWindow::SubclassWin(HWND__*) () from D:\code\wxWidgets-3.1.0\lib\gcc_dll\wxmsw310u_gcc_cb.dll
[debug]#24 0x75bc965e in USER32!GetWindow () from C:\windows\syswow64\user32.dll
[debug]#25 0x00000000 in ?? ()
[debug]>>>>>>cb_gdb:


Here, the value "*.abc" is just overwriten by the "*.*". Thus my customized value is lost.
I'm not sure why the event below happens.
Code: [Select]
void DirectoryParamsPanel::OnSearchMaskTextEvent(wxCommandEvent &event)
{
    m_pFindData->SetSearchMask(event.GetString());
    event.Skip();
}

In my original problem, a crash happens when we call "event.GetString()", but that is another crash issue, which can be workaround by adding the "O0" optimization decoration to the function(I wrote that in my previous posts).

 :(
« Last Edit: October 28, 2017, 10:18:29 am by ollydbg »
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.

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10357
Re: Threadsearch plugin cause crash when initilized (wx3.1,C::B svn head)
« Reply #21 on: October 28, 2017, 12:10:06 pm »
Works perfectly fine here. There is something broken in your build.
Do you see the same problem with the night build?
<debugger plugin maintainer>
(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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 4982
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Threadsearch plugin cause crash when initilized (wx3.1,C::B svn head)
« Reply #22 on: October 28, 2017, 01:06:46 pm »
Works perfectly fine here.
You are using Linux, right?

Quote
There is something broken in your build.
Do you see the same problem with the night build?
This issue does not exist in nightly build which is wx2.8 based.
I suggest someone using wx3.1 based C::B under Windows would test it. Thanks.
« Last Edit: October 28, 2017, 01:12:54 pm by ollydbg »
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.

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10357
Re: Threadsearch plugin cause crash when initilized (wx3.1,C::B svn head)
« Reply #23 on: October 28, 2017, 04:46:32 pm »
Yes, linux, wx3.0.2 and wx-master all built with gcc-5.4. But I'm building for 64bit all the time. So it is not too relevant.
<debugger plugin maintainer>
(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!]