pmem / libpmemobj-cpp

C++ bindings & containers for libpmemobj
https://pmem.io
Other
108 stars 76 forks source link

operator-- may fail in concurrent radix_tree #1159

Open lukaszstolarczuk opened 3 years ago

lukaszstolarczuk commented 3 years ago

operator-- may fail (when MtMode is enabled) in some specific cases, e.g.:

ref. #1156

igchor commented 3 years ago

There are two problems for this version: https://github.com/pmem/libpmemobj-cpp/commit/63009805933a643208af47624b3ec7be3d56b57e

  1. If iterator points to end() and trydecrement fails, we will call key() on nullptr (leaf == nullptr for end())
  2. Problem mentioned by lukaszstolarczuk is caused by a lack of special value for begin(). When we use operator++ and encounter end() we know it's time to stop. For operator-- be cannot rely on comparison with begin() since its value can change. We could introduce a special past-begin iterator for this purpose.