Author Topic: Crash in BrowseTracker using wxsmith  (Read 355 times)

Offline gd_on

  • Regular
  • ***
  • Posts: 419
Crash in BrowseTracker using wxsmith
« on: October 26, 2018, 10:56:22 am »
I build a GUI application with wxsmith.
For example, I have a toto.wxs file, and a toto.cpp file and a toto.h file (both initially built by wxsmith).
If I click somewhere in my cpp file, then click somewhere in my .h file, I can use the BrowseTracker green arrow in the toolbar to switch back to the place I was in my .cpp file. That's OK.
Now, I look in my wxs file, presented as a GUI (obtained by a click on toto.wxs in the project workspace Gui / Resources / wxsmith ). There, I can add, modify some properties, add elements, ... OK.
If now, I click on the  BrowseTracker green arrow, which should normally switch back to my .cpp (or .h) file (I supppose), C::B crashes in BrowseTracker (see the rpt file).
This problem is not new but I can't remember when it appeared for the first time, sorry.

gd_on

I'm on Windows 7, C::B svn 11506 built with wxwidgets 3.11 in 64 bits, built with TDM 4.9.2 compilers but it happens also with other C::B builds with other compilers (7.3, 8.1 for example, 64 and 32 bits builds).
Windows 10 or 7, svn C::B (last version or almost!), WxWidgets 2.8.12, Compilers TDM 4.9.2 32 bits (gcc and gfortran installed in C:\MinGW32). Tests with C::B 64 bits and WxWidgets 2.8.12 or 3.1.1 (64 bits) compiled by TDM 4.9.2 in C:\MinGW64

Online BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2065
Re: Crash in BrowseTracker using wxsmith
« Reply #1 on: October 26, 2018, 01:36:21 pm »
Can reproduce:
proper backtrace:
Code: [Select]
#0 0x6de58cf5 JumpTracker::OnMenuJumpBack(this=0xe8706e0) (wxPath\CB-Test\git_1\codeblocks_sf\src\plugins\contrib\BrowseTracker\JumpTracker.cpp:636)
#1 0x6a084074 wxAppConsoleBase::HandleEvent(wxEvtHandler*, void (wxEvtHandler::*)(wxEvent&) (wxPath\wxWidgets-3.0.4\lib\gcc_dll\wxmsw30u_gcc_custom.dll:??)
#2 0x6a0840d0 wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const() (wxPath\wxWidgets-3.0.4\lib\gcc_dll\wxmsw30u_gcc_custom.dll:??)
#3 0x6a1a6f8d wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () (wxPath\wxWidgets-3.0.4\lib\gcc_dll\wxmsw30u_gcc_custom.dll:??)
#4 0x6a1a7bf8 wxEvtHandler::SearchDynamicEventTable(wxEvent&) () (wxPath\wxWidgets-3.0.4\lib\gcc_dll\wxmsw30u_gcc_custom.dll:??)
#5 0x6a1a742b wxEvtHandler::TryHereOnly(wxEvent&) () (wxPath\wxWidgets-3.0.4\lib\gcc_dll\wxmsw30u_gcc_custom.dll:??)
#6 0x6a99b70c wxEvtHandler::TryBeforeAndHere(wxEvent&) () (wxPath\wxWidgets-3.0.4\lib\gcc_dll\wxmsw30u_gcc_custom.dll:??)
#7 0x6a1a71ef wxEvtHandler::ProcessEvent(wxEvent&) () (wxPath\wxWidgets-3.0.4\lib\gcc_dll\wxmsw30u_gcc_custom.dll:??)
#8 0x6a1a7319 wxEvtHandler::DoTryChain(wxEvent&) () (wxPath\wxWidgets-3.0.4\lib\gcc_dll\wxmsw30u_gcc_custom.dll:??)
#9 0x6a1a727a wxEvtHandler::ProcessEventLocally(wxEvent&) () (wxPath\wxWidgets-3.0.4\lib\gcc_dll\wxmsw30u_gcc_custom.dll:??)
#10 0x6a1a7204 wxEvtHandler::ProcessEvent(wxEvent&) () (wxPath\wxWidgets-3.0.4\lib\gcc_dll\wxmsw30u_gcc_custom.dll:??)
#11 0x6a3da42a wxWindowBase::TryAfter(wxEvent&) () (wxPath\wxWidgets-3.0.4\lib\gcc_dll\wxmsw30u_gcc_custom.dll:??)
#12 0x6a1a722f wxEvtHandler::ProcessEvent(wxEvent&) () (wxPath\wxWidgets-3.0.4\lib\gcc_dll\wxmsw30u_gcc_custom.dll:??)
#13 0x6a1a7534 wxEvtHandler::SafelyProcessEvent(wxEvent&) () (wxPath\wxWidgets-3.0.4\lib\gcc_dll\wxmsw30u_gcc_custom.dll:??)
#14 0x6a3d3c7e wxWindowBase::HandleWindowEvent(wxEvent&) const() (wxPath\wxWidgets-3.0.4\lib\gcc_dll\wxmsw30u_gcc_custom.dll:??)
#15 0x6a3bf2af wxToolBarBase::OnLeftClick(int, bool) () (wxPath\wxWidgets-3.0.4\lib\gcc_dll\wxmsw30u_gcc_custom.dll:??)
#16 0x6a2c3840 wxToolBar::MSWCommand(unsigned int, unsigned short) () (wxPath\wxWidgets-3.0.4\lib\gcc_dll\wxmsw30u_gcc_custom.dll:??)
#17 0x6a24cb8c wxWindow::HandleCommand(unsigned short, unsigned short, HWND__*) () (wxPath\wxWidgets-3.0.4\lib\gcc_dll\wxmsw30u_gcc_custom.dll:??)
#18 0x6a27f713 wxFrame::HandleCommand(unsigned short, unsigned short, HWND__*) () (wxPath\wxWidgets-3.0.4\lib\gcc_dll\wxmsw30u_gcc_custom.dll:??)
#19 0x6a27f84a wxFrame::MSWWindowProc(unsigned int, unsigned int, long) () (wxPath\wxWidgets-3.0.4\lib\gcc_dll\wxmsw30u_gcc_custom.dll:??)
#20 0x6a24417f wxWndProc(HWND__*, unsigned int, unsigned int, long)@16() (wxPath\wxWidgets-3.0.4\lib\gcc_dll\wxmsw30u_gcc_custom.dll:??)
#21 0x76a162fa gapfnScSendMessage() (C:\Windows\syswow64\user32.dll:??)
#22 0x30c74 ?? () (??:??)
#23 0x76a16d3a USER32!GetThreadDesktop() (C:\Windows\syswow64\user32.dll:??)
#24 0x6a2440d6 wxWindowCreationHook::~wxWindowCreationHook() () (wxPath\wxWidgets-3.0.4\lib\gcc_dll\wxmsw30u_gcc_custom.dll:??)
#25 0x76a1965e USER32!GetWindow() (C:\Windows\syswow64\user32.dll:??)
#26 ?? ?? () (??:??)

culprit:
Code: [Select]
void JumpTracker::OnMenuJumpBack(wxCommandEvent &/*event*/)
// ----------------------------------------------------------------------------
{
    #if defined(LOGGING)
    LOGIT( _T("JT [%s]"), _T("OnMenuJumpBack"));
    #endif

    int knt = m_ArrayOfJumpData.GetCount();
    if (0 == knt)
        return;

    // If not wrapping && we're about to backup into the insert index, return
    if (not m_bWrapJumpEntries)
        if (GetPreviousIndex(m_cursor) == m_insertNext)
            return;

    m_bJumpInProgress = true;

    EditorManager* edmgr = Manager::Get()->GetEditorManager();
    EditorBase* eb = edmgr->GetActiveEditor();
    cbEditor* cbed = edmgr->GetBuiltinEditor(eb);
    //-long activeEdLine = 0;
    long activeEdPosn = 0;
    wxString activeEdFilename = wxEmptyString;
    if (cbed)
    {
        //-activeEdLine = cbed->GetControl()->GetCurrentLine();
        activeEdPosn = cbed->GetControl()->GetCurrentPos();
        activeEdFilename = cbed->GetFilename();
    }

    // if active editor line == m_cursor, back up the m_cursor
    // until finding an entry that does not match this m_cursor entry.
    // else
    // find the previous m_insertNext entry that does not match this editor or line number

    do {    // find the previous appropriate jump position

        // if current cursor position is also current editor and line,
        // return the previous m_cursor entry
        if ( JumpDataContains(m_cursor, cbed->GetFilename(), activeEdPosn))
        {
            // FIXME (ph#): a dead editor can be returned here
            m_cursor = GetPreviousIndex(m_cursor);
        }
        else    //find an entry (backward) from the insertion point
        {

Code: [Select]
cbed is 0 and there is no null pointer check

Online BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2065
Re: Crash in BrowseTracker using wxsmith
« Reply #2 on: October 26, 2018, 03:34:41 pm »
I tried to fix this
Resolving the crash is easy, but making it work properly is bit more dificult...

Does someone know why wxSmith editors return only a relative path from cbEditorBase::GetFilename() and not like all editors absolute paths?
Is there a way to get the full path from a relative path?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5109
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Crash in BrowseTracker using wxsmith
« Reply #3 on: October 27, 2018, 03:14:45 am »
I got the same backtrace.
The wxsmith design GUI is not a buildin editor, so it returns nullptr.
« Last Edit: October 27, 2018, 06:56:39 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 Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2106
Re: Crash in BrowseTracker using wxsmith
« Reply #4 on: October 27, 2018, 08:44:24 pm »
Fixed in r11508.
Thanks BlueHazzard and ollydbg.

Offline gd_on

  • Regular
  • ***
  • Posts: 419
Re: Crash in BrowseTracker using wxsmith
« Reply #5 on: October 28, 2018, 03:23:19 pm »
Thanks.
Does not return to the previous place from the wxs file, but does not crash. So, better!
gd_on
Windows 10 or 7, svn C::B (last version or almost!), WxWidgets 2.8.12, Compilers TDM 4.9.2 32 bits (gcc and gfortran installed in C:\MinGW32). Tests with C::B 64 bits and WxWidgets 2.8.12 or 3.1.1 (64 bits) compiled by TDM 4.9.2 in C:\MinGW64

Online BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2065
Re: Crash in BrowseTracker using wxsmith
« Reply #6 on: October 28, 2018, 03:34:30 pm »
Quote
Does not return to the previous place from the wxs file, but does not crash. So, better!
i was talking about this when i mentioned
Resolving the crash is easy, but making it work properly is bit more dificult...

The problem is that we do not have a unique identifier for tabs... The GetFilename, what is used now by the plugin, is not enough to identify the tab in wxSmith... (as far as i can see)