I have compiled C::B with the "official" Bretch Sander's compiler, and get a consistent crash on start.
Thread 1 received signal SIGSEGV, Segmentation fault.
#0 0x000007fee574e40f in wxBitmapBundle::operator=(wxBitmapBundle const&) () from C:\Windows\system32\wxmsw331u_gcc_custom.dll
#1 0x000007fee5866564 in __gnu_cxx::__normal_iterator<wxAuiNotebookPage*, std::vector<wxAuiNotebookPage, std::allocator<wxAuiNotebo
okPage> > > std::_V2::__rotate<__gnu_cxx::__normal_iterator<wxAuiNotebookPage*, std::vector<wxAuiNotebookPage, std::allocator<wxAuiN
otebookPage> > > >(__gnu_cxx::__normal_iterator<wxAuiNotebookPage*, std::vector<wxAuiNotebookPage, std::allocator<wxAuiNotebookPage>
> >, __gnu_cxx::__normal_iterator<wxAuiNotebookPage*, std::vector<wxAuiNotebookPage, std::allocator<wxAuiNotebookPage> > >, __gnu_c
xx::__normal_iterator<wxAuiNotebookPage*, std::vector<wxAuiNotebookPage, std::allocator<wxAuiNotebookPage> > >, std::random_access_i
terator_tag) [clone .isra.0] () from C:\Windows\system32\wxmsw331u_gcc_custom.dll
#2 0x000007fee5867a13 in wxAuiTabContainer::MovePage(unsigned long long, unsigned long long) ()
from C:\Windows\system32\wxmsw331u_gcc_custom.dll
#3 0x000007fed4618868 in cbAuiNotebook::MovePage (this=0x359e6a0, page=0x8379470, new_idx=7)
at G:\codeblocks\src\sdk\cbauibook.cpp:498
#4 0x000000013f15742b in InfoPane::ReorderTabs (this=0x359e6a0,
cmp_f=0x13f1571e0 <InfoPane::CompareIndexes(InfoPane::Page**, InfoPane::Page**)>) at G:\codeblocks\src\src\infopane.cpp:153
#5 0x000000013f1570f7 in InfoPane::LoadTabOrder (this=0x359e6a0, layout=...) at G:\codeblocks\src\src\infopane.cpp:119
#6 0x000000013f164575 in MainFrame::LoadViewLayout (this=0x3445220, name=..., isTemp=false) at G:\codeblocks\src\src\main.cpp:1862
#7 0x000000013f163121 in MainFrame::LoadWindowState (this=0x3445220) at G:\codeblocks\src\src\main.cpp:1717
#8 0x000000013f15ab34 in MainFrame::MainFrame (this=0x3445220, parent=0x0) at G:\codeblocks\src\src\main.cpp:821
#9 0x000000013f103456 in CodeBlocksApp::InitFrame (this=0x366690) at G:\codeblocks\src\src\app.cpp:523
#10 0x000000013f104dd2 in CodeBlocksApp::OnInit (this=0x366690) at G:\codeblocks\src\src\app.cpp:754
#11 0x000000013f1ff3b5 in wxAppConsoleBase::CallOnInit (this=0x366690) at C:/Librerias151/wxWidgets-3.3.1/include/wx/app.h:92
#12 0x000007fee529a007 in wxEntryReal(int&, wchar_t**) () from C:\Windows\system32\wxmsw331u_gcc_custom.dll
#13 0x000000013f102721 in WinMain (hInstance=0x13f100000, hPrevInstance=0x0, lpCmdLine=0x28428e "", nCmdShow=10)
at G:\codeblocks\src\src\app.cpp:334
#14 0x000000013f1dd364 in main ()
I have isolated the problem to this code:
void InfoPane::ReorderTabs(CompareFunction cmp_f)
{
if (m_Pages.GetCount() == 0)
return;
m_Pages.Sort(cmp_f);
cbAuiNotebook::Hide();
int index = 0;
for (size_t i = 0 ; i < m_Pages.GetCount(); ++i)
{
int pageIndex = GetPageIndex(m_Pages.Item(i)->window);
if (m_Pages.Item(i)->indexInNB < 0)
{
if (pageIndex >= 0)
RemovePage(pageIndex);
if (m_Pages.Item(i)->window)
m_Pages.Item(i)->window->Hide();
}
else
{
if (pageIndex < 0)
AddPagePrivate(m_Pages.Item(i)->window, m_Pages.Item(i)->title, m_Pages.Item(i)->icon);
if (index++ != pageIndex)
MovePage(m_Pages.Item(i)->window, index ); <------- HERE
}
}
cbAuiNotebook::Show();
}
where in the call to MovePage()
index is equal to the number of pages in the notebook, so the call to std::rotate uses an invalid iterator.
I have tried to fix the logic, but only got a corruption of the layout when closing C::B. A check for index < GetPageCount() works, but IMHO fixing the logic is better.
Failed attempt:
if (index != pageIndex)
MovePage(m_Pages.Item(i)->window, index);
index++;
Working but undesired attempt:
if (index++ != pageIndex)
if (index < (int)GetPageCount())
MovePage(m_Pages.Item(i)->window, index);
Any ideas?
EDIT: The code in wxAuiTabContainer::MovePage() has been completely changed from wx3.2.8 to wx3.3.1, now uses std::rotate()