Opened 7 years ago

Closed 7 years ago

#11533 closed Bugs (fixed)

rtree segfault / assertion failure

Reported by: gewesp@… Owned by: awulkiew
Milestone: Boost 1.60.0 Component: geometry
Version: Boost 1.59.0 Severity: Problem
Keywords: rtree, remove, assert Cc:

Description

I have occasional segfaults in the production version of KTrax: http://ktrax.kisstech.ch/ktrax/

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.

./rtree-crash 15 4 [...] Assertion failed: ((!children.empty())&&("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.

The bug hits if elements are added, then removed in a different order to zero size(), then others are added again.

Some observations:

  • Crash doesn't seem to depend on the coordinates of elements added.
  • Crash reproducible with dimension 1, 2, possibly also higher.
  • Crash reproducible with integer or double coordinates.
  • Minimum example found is with 14 elements.
  • Crash seems reproducible only if *all* elements are removed, but this is not verified.
  • Versions tried: 1.58.0 (Mac) and 1.55.0 (Linux)
  • Compilers tried on Mac: clang++, g++

Attachments (1)

rtree-crash.cpp (1.6 KB ) - added by gewesp@… 7 years ago.

Download all attachments as: .zip

Change History (4)

by gewesp@…, 7 years ago

Attachment: rtree-crash.cpp added

comment:1 by awulkiew, 7 years ago

Keywords: rtree remove assert added
Owner: changed from Barend Gehrels to awulkiew

Thanks for the report!

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: https://github.com/boostorg/geometry/commit/098279e7399efad87cc67d1e211b2b6a2e8495d8

Unfortunately it probably won't make it to Boost 1.59.

A workaround would be to define some greater number of min elements than 1, e.g.:

quadratic<4, 2>

comment:2 by gewesp@…, 7 years ago

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.

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.

I'll try ASAP, on vacation right now.

comment:3 by awulkiew, 7 years ago

Milestone: To Be DeterminedBoost 1.60.0
Resolution: fixed
Status: newclosed
Version: Boost 1.58.0Boost 1.59.0

It should be possible to apply it to 1.55. In this case you only need to patch the remove visitor.

I tested develop branch (1.59+) against the code you sent. Test case was added as well.

I'm closing the ticket. If the problem was still there you could just reopen it.

Note: See TracTickets for help on using tickets.