Re: [Boost-bugs] [Boost C++ Libraries] #12861: Segmentation fault when creating R-tree with packing algorithm with gcc4.8.2

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #12861: Segmentation fault when creating R-tree with packing algorithm with gcc4.8.2
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-02-25 00:35:09


#12861: Segmentation fault when creating R-tree with packing algorithm with
gcc4.8.2
---------------------------------+----------------------
  Reporter: michael.moessner@… | Owner: awulkiew
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: geometry
   Version: Boost 1.63.0 | Severity: Problem
Resolution: | Keywords: rtree
---------------------------------+----------------------

Comment (by awulkiew):

 I was able to reproduce it. It is a bug in libstdc++ in
 `std::nth_element()` function, see:
 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58800

 For your data `__unguarded_partition` goes out of bounds for a case
 similar to this (values below are z coordinates of centroids of some
 boxes):

 {{{
 std::vector<float> vec = {3.94167948, 2.87522459, 4.17142391, 3.00844622};
 std::nth_element(vec.begin(), vec.begin() + 2, vec.end());
 }}}

 It seems that `std::sort` doesn't have this problem so it could be called
 instead for specific version of gcc/libstdc++. So instead of a SEGFAULT
 the rtree would be slower. If I figured out how reliable is the timestamp
 defined by `__GLIBCXX__` in this case I could conditionally call
 `std::sort`. At the GCC bug page they wrote that several GCC versions were
 affected (Fixed for 4.7.4/4.8.3/4.9.0.) and the timestamp may be set to
 different value for different compilers, so IDK. At the moment I could
 enable it for this specific version I've used, `__GLIBCXX__` is
 `20131016`. Is it the same for you? Do you have any suggestions?

 As a workaround you can either update gcc/libstdc++ or alter your local
 copy of Boost by replacing `std::nth_element` calls with `std::sort`
 calls. Just use `grep` to find them in `boost/geometry`. There are some
 calls in the rstar balancing algorithm and one call in packing algorithm,
 here:
 https://github.com/boostorg/geometry/blob/develop/include/boost/geometry/index/detail/rtree/pack_create.hpp#L70
 which could be replaced with:


 {{{
 std::sort(first, last, point_entries_comparer<I>());
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12861#comment:6>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-25 00:38:49 UTC