Boost C++ Libraries: Ticket #11533: rtree segfault / assertion failure https://svn.boost.org/trac10/ticket/11533 <p> I have occasional segfaults in the production version of KTrax: <a class="ext-link" href="http://ktrax.kisstech.ch/ktrax/"><span class="icon">​</span>http://ktrax.kisstech.ch/ktrax/</a> </p> <p> I've been able to trace the problem to what I believe is a bug in boost::geometry. A reduced standalone example to reproduce the problem is attached. </p> <p> ./rtree-crash 15 4 [...] Assertion failed: ((!children.empty())&amp;&amp;("can't choose the next node if children are empty")), function apply, file /opt/local/include/boost/geometry/index/detail/rtree/visitors/insert.hpp, line 46. </p> <p> The bug hits if elements are added, then removed in a different order to zero size(), then others are added again. </p> <p> Some observations: </p> <ul><li>Crash doesn't seem to depend on the coordinates of elements added. </li><li>Crash reproducible with dimension 1, 2, possibly also higher. </li><li>Crash reproducible with integer or double coordinates. </li><li>Minimum example found is with 14 elements. </li><li>Crash seems reproducible only if *all* elements are removed, but this is not verified. </li><li>Versions tried: 1.58.0 (Mac) and 1.55.0 (Linux) </li><li>Compilers tried on Mac: clang++, g++ </li></ul> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11533 Trac 1.4.3 gewesp@… Tue, 11 Aug 2015 16:15:30 GMT attachment set https://svn.boost.org/trac10/ticket/11533 https://svn.boost.org/trac10/ticket/11533 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">rtree-crash.cpp</span> </li> </ul> Ticket awulkiew Wed, 12 Aug 2015 23:00:28 GMT owner changed; keywords set https://svn.boost.org/trac10/ticket/11533#comment:1 https://svn.boost.org/trac10/ticket/11533#comment:1 <ul> <li><strong>keywords</strong> rtree remove assert added </li> <li><strong>owner</strong> changed from <span class="trac-author">Barend Gehrels</span> to <span class="trac-author">awulkiew</span> </li> </ul> <p> Thanks for the report! </p> <p> The removal doesn't work correctly when the min elements number is 1. I pushed a fix which you could apply to your local copy of Boost and check if it solves the issue for you: <a class="ext-link" href="https://github.com/boostorg/geometry/commit/098279e7399efad87cc67d1e211b2b6a2e8495d8"><span class="icon">​</span>https://github.com/boostorg/geometry/commit/098279e7399efad87cc67d1e211b2b6a2e8495d8</a> </p> <p> Unfortunately it probably won't make it to Boost 1.59. </p> <p> A workaround would be to define some greater number of min elements than 1, e.g.: </p> <pre class="wiki">quadratic&lt;4, 2&gt; </pre> Ticket gewesp@… Thu, 13 Aug 2015 06:34:04 GMT <link>https://svn.boost.org/trac10/ticket/11533#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11533#comment:2</guid> <description> <p> Thanks a lot for the quick fix (and for the library in the first place)! Can I also apply it to boost 1.55? That's the version I'm using in production. </p> <p> Did you try it against the test case in rtree-crash.cpp? If it fixes that one, it very likely also fixes my production problem. I also suggest adding the test case to the test suite. </p> <p> I'll try ASAP, on vacation right now. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>awulkiew</dc:creator> <pubDate>Thu, 13 Aug 2015 19:28:02 GMT</pubDate> <title>status, version, milestone changed; resolution set https://svn.boost.org/trac10/ticket/11533#comment:3 https://svn.boost.org/trac10/ticket/11533#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost 1.58.0</span> → <span class="trac-field-new">Boost 1.59.0</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.60.0</span> </li> </ul> <p> It should be possible to apply it to 1.55. In this case you only need to patch the remove visitor. </p> <p> I tested develop branch (1.59+) against the code you sent. Test case was added as well. </p> <p> I'm closing the ticket. If the problem was still there you could just reopen it. </p> Ticket