tzaeschke / phtree-cpp

PH-Tree C++ implementation
Apache License 2.0
29 stars 9 forks source link

phtree_multimap_d_test fails with NUM_DUPL = 10 #154

Open tzaeschke opened 1 year ago

tzaeschke commented 1 year ago

The phtree_multimap_d_test fails when setting NUM_DUPL = 10. Specifically, the PhTreeMMDTest.TestUpdateWithEmplaceHint test fails with core dump.

Tested with: Ubuntu 22.04, gcc 12.3, ASAN enabled

This problem occurs only in the following scenario:

auto iter = find(p1, ..);
erase(p1, ...);
emplace_hint(iter, p2);

Reusing iter after erase() looks very dangerous, but should be alright in this scenario, emplace_hint has actually been designed to work with iterators after a single erase() occurred. However, in this case it does not appear to work, either because the returned iterator is wrong (unlikely) or because emplace_hint() does not handle the iterator correctly.

The result is that emplace_hint() inserts the entry at the wrong location.