Since wx3.x, symbols browser of CC was disabled because of crash.
However, I think I need this basic function, so, I re-open the function code of CC and do a two hours test,
and found the problem of CC plugin:
1) It do GUI operations within worker thread although there is some protection, which will make it crashing
in xcb library.
>> For this issue, I just rebuild the symbols tree with GUI main thread simply, then, the xcb crash disappear.
but it still would crash frequently.
I took two hours to do a black-box test, and found it crashed only for some files, so, i create such a simple
project only included some files might cause the issue. And found the crash just because sort the symbols
tree node. tree->SortChildren, which is the standard interface of wx!
I traced the crash and found the issue in std::sort. My OS is GNU/Slackware, with gcc-9.2, and the crash
point located in: /usr/include/c++/9.2.0/bits/stl_algo.h
/// This is a helper function for the sort routine.
template<typename _RandomAccessIterator, typename _Compare>
void
__unguarded_linear_insert(_RandomAccessIterator __last,
_Compare __comp)
{
typename iterator_traits<_RandomAccessIterator>::value_type
__val = _GLIBCXX_MOVE(*__last);
_RandomAccessIterator __next = __last;
--__next;
while (__comp(__val, __next)) ---->ISSUE: might go ahead of the first iterator
{
*__last = _GLIBCXX_MOVE(*__next);
__last = __next;
--__next;
}
*__last = _GLIBCXX_MOVE(__val);
}
and found the other issue:
2) the non-deterministic compares will make std::sort(Introspective Sort)'s second step will go ahead the the head of the
vector array, which lead a invalid reference.
if (!lhs || !rhs)
return 1;
if (lhs->m_SpecialFolder != sfToken || rhs->m_SpecialFolder != sfToken)
return -1;
if (!lhs->m_Token || !rhs->m_Token)
return 1;
the code slice above is cited from CCTreeCtrl's treenode compare function, that will got some non-deterministic order
of some items. I simple fixed by expanding the || operation.
Because my locale code is different with the svn code, I just packaged my changed in a tarball and uploaded it here.
I submitted my simple solution at:
https://github.com/kipade/codeblocks_sf/commit/f607bfb8e2f23645ba3f2e1900d41bea488fb081I tested the solution on my computer. My environment is:
GNU/Slackware X86_64, current, with wx3.1.3
You are welcome to test it. And I home some developers can make a professional fix the release the right version.