Skip to content

Commit be38ee4

Browse files
hageboeckdpiparo
authored andcommitted
[RDF] Fix a crash caused by an iterator invalidation.
This is a followup of the fix #20352 for issue #20320: When snapshot with variations is run with JIT-ted filters, the computation graph first needs to be JIT-ted before reading Defines or Filters. In the fix for that case, an iterator invalidation on push_back caused crashes, because vector.reserve() had been called with the wrong size. Here, the size is corrected, but more importantly, instead of saving the iterator, the shared_ptr it points to is saved. This makes the code independent of the underlying storage. (cherry picked from commit 886abae)
1 parent 5bbd061 commit be38ee4

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

tree/dataframe/inc/ROOT/RDF/RActionSnapshot.hxx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,28 +64,25 @@ class R__CLING_PTRCHECK(off) RActionSnapshot final : public RActionBase {
6464
const auto &currentVariations = GetVariations();
6565

6666
// If this node hangs from the RLoopManager itself, just use that as the upstream node for each variation
67-
auto nominalPrevNode = fPrevNodes.begin();
68-
if (static_cast<ROOT::Detail::RDF::RNodeBase *>(nominalPrevNode->get()) == fLoopManager) {
69-
fPrevNodes.resize(1 + currentVariations.size(), *nominalPrevNode);
67+
auto nominalPrevNode = fPrevNodes.front();
68+
if (static_cast<ROOT::Detail::RDF::RNodeBase *>(nominalPrevNode.get()) == fLoopManager) {
69+
fPrevNodes.resize(1 + currentVariations.size(), nominalPrevNode);
7070
return;
7171
}
7272

7373
// Otherwise, append one varied filter per variation
74-
const auto &prevVariations = (*nominalPrevNode)->GetVariations();
75-
76-
fPrevNodes.reserve(1 + prevVariations.size());
77-
// Get valid iterator after resizing
78-
nominalPrevNode = fPrevNodes.begin();
74+
const auto &prevVariations = nominalPrevNode->GetVariations();
75+
fPrevNodes.reserve(1 + currentVariations.size());
7976

8077
// Need to populate parts of the computation graph for which we have empty shells, e.g. RJittedFilters
8178
if (!currentVariations.empty())
8279
fLoopManager->Jit();
8380
for (const auto &variation : currentVariations) {
8481
if (IsStrInVec(variation, prevVariations)) {
8582
fPrevNodes.emplace_back(
86-
std::static_pointer_cast<PrevNodeCommon_t>((*nominalPrevNode)->GetVariedFilter(variation)));
83+
std::static_pointer_cast<PrevNodeCommon_t>(nominalPrevNode->GetVariedFilter(variation)));
8784
} else {
88-
fPrevNodes.push_back(*nominalPrevNode);
85+
fPrevNodes.push_back(nominalPrevNode);
8986
}
9087
}
9188
}

0 commit comments

Comments
 (0)