Skip to content

Commit

Permalink
add missing lock for _mutOverlaps. This is most likely the culprit fo…
Browse files Browse the repository at this point in the history
…r the invalid mid encountered (which also isn't a valid geometry cache offset because it translates to a file offset of 130 TB, so it must originate from memory corruption). Without the lock, concurrent write and read access to _subNotOverlaps is possible, which also invalidates the iterators used in multiOut() - after that, anything goes. Also remove the silent skip if an invalid mid is encounted (this should never happen) and add a WARN log instead.
  • Loading branch information
patrickbr committed May 10, 2024
1 parent 762d9a3 commit a0a97c7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/spatialjoin/Sweeper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ void Sweeper::clearMultis(bool force) {
for (auto a = _activeMultis.begin(); a != _activeMultis.end();) {
size_t mid = *a;
if (mid >= _multiIds.size()) {
// TODO: Just skip or erase and skip?
LOG(WARN) << "Invalid multi ID " << mid << " detected!";
a++;
continue;
}
Expand Down Expand Up @@ -373,7 +373,8 @@ void Sweeper::multiOut(size_t t, const std::string& gidA) {
auto gidB = b.first;
if (b.second.size() == _subSizes[gidA]) continue;

std::unique_lock<std::mutex> lock(_mutNotOverlaps);
std::unique_lock<std::mutex> lock(_mutOverlaps);
std::unique_lock<std::mutex> lock2(_mutNotOverlaps);
if (!notOverlaps(gidA, gidB)) {
writeRel(t, gidA, gidB, _cfg.sepOverlaps);
writeRel(t, gidB, gidA, _cfg.sepOverlaps);
Expand Down

0 comments on commit a0a97c7

Please sign in to comment.