#15747 closed defect (fixed)

Segfault calling wxAuiToolBar::GetToolBarFits().

Reported by: stambaughw Owned by:
Priority: normal Milestone:
Component: wxAui Version: 3.0.0
Keywords: Cc:
Blocked By: Blocking:
Patch: no

Description

I get the following segfault:

0x6a1a67a6 in GetToolFitsByIndex (tool_idx=11, this=0x3fb134b8)

at C:/MinGW/msys/1.0/home/Wayne/src/wxWidgets-3.0.0/src/aui/auibar.cpp:1785

1785 cli_w -= m_overflowSizerItem->GetSize().x;

when calling wxAuiToolBar::GetToolBarFits() when the wxAUI_TB_OVERFLOW flag is not set in the style argument when creating the tool bar. Obviously the problem is m_overflowSizeItem is NULL. My guess is the best place to fix this is within GetToolFitsByIndex rather than GetToolBarFits but I will leave that up to your expertise. Also, you may want to look at all of the other places m_overflowSizeItem is used in auibar.cpp. I don't think this is the only place where this issue can occur. I checked trunk and this problem still exists.

The only reason I found this problem may be the result of another issue with the tool bar overflow behavior. I was under the impression that the overflow control would only be displayed when the tool bar does not fit in it's parent window but my experience (at least on Windows) is that it is always shown so I was attempting to set the overflow control visibility when the window is resized or the tool bar is moved or resized.

Attachments (1)

auidemo.cpp download (67.3 KB) - added by stambaughw 11 months ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 11 months ago by vadz

  • Milestone 3.0.1 deleted
  • Status changed from new to infoneeded_new

Could you please provide a minimal patch to the aui sample allowing to reproduce the problem? I don't understand how to achieve the situation in which m_overflowVisible is true, yet m_overflowSizerItem is NULL...

Changed 11 months ago by stambaughw

comment:2 Changed 11 months ago by stambaughw

  • Status changed from infoneeded_new to new

I have attached a modified version of auidemo.cpp that recreates the problem. Simply copy the file to the samples/aui folder in a wxWidgets source tree and build as desired. The executable will segfault at load at GetToolBarFits() (line 817) in the MyFrame constructor in the same manner described in the original bug report.

comment:3 Changed 11 months ago by vadz

It doesn't crash on load for me but I can crash it later by resizing the window. I still don't understand how exactly is this code supposed to work to be honest, but I'll apply the straightforward fix as anything is still better than crashing.

Thanks!

comment:4 Changed 11 months ago by VZ

(In [75399]) Don't crash in wxAuiToolBar::GetToolBarFits().

The code could crash if m_overflowVisible was true but m_overflowSizerItem was
NULL. Ideally this shouldn't happen in the first place, but it did, so at
least fix the crash for now -- and hopefully this code will be refactored to
make it more clear later.

Backport from trunk, see #15747.

comment:5 Changed 11 months ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [75400]) Don't crash in wxAuiToolBar::GetToolBarFits().

The code could crash if m_overflowVisible was true but m_overflowSizerItem was
NULL. Ideally this shouldn't happen in the first place, but it did, so at
least fix the crash for now -- and hopefully this code will be refactored to
make it more clear later.

Closes #15747.

Note: See TracTickets for help on using tickets.