Skip to content

Conversation

vepadulano
Copy link
Member

Fixes #19814 and also the recent CI failures such as https://github.com/root-project/root/actions/runs/17610706130/job/50031825233?pr=19860#step:6:4762

The second commit contains the main change: reworking the TChain::GetEntries method. The issue with it was that it was causing one side-effect too many: the last opened file was not being properly closed. This in turn triggered the if condition in TTreeReader::Restart and the segfaults due to bad memory accesses. This is an alternative solution to #19866 . The advantage IMHO is that it requires changing fewer places and better conveys the intent of the method: a for loop opening the files as opposed to calling LoadTree until all files have been opened. On top of course of having far less side-effects (AFAICT none).

@vepadulano vepadulano self-assigned this Sep 12, 2025
@vepadulano vepadulano requested a review from pcanal as a code owner September 12, 2025 10:35
Copy link

github-actions bot commented Sep 12, 2025

Test Results

    20 files      20 suites   3d 15h 15m 49s ⏱️
 3 664 tests  3 390 ✅   0 💤 274 ❌
71 468 runs  70 853 ✅ 341 💤 274 ❌

For more details on these failures, see this check.

Results for commit 0608255.

♻️ This comment has been updated with latest results.

@vepadulano
Copy link
Member Author

vepadulano commented Sep 12, 2025

Turns out there are even more side-effects caused by TChain::GetEntries than I could see/foresee :)

vepadulano and others added 2 commits September 12, 2025 15:44
Instead of relying on TChain::LoadTree to compute the total number of entries, which has guaranteed side-effects, switch to a simpler accumulation algorithm by opening just the files of the chain. Use the READ_WITHOUT_GLOBAL_REGISTRATION option to avoid possible side-effects in this case as well.
@vepadulano vepadulano requested a review from dpiparo as a code owner September 12, 2025 16:10
@vepadulano
Copy link
Member Author

@pcanal I implemented the changes we discussed in the last commit. Let me know what you think and let's see if the CI will agree with us.

@vepadulano vepadulano requested a review from pcanal September 12, 2025 18:17
Copy link
Collaborator

@ferdymercury ferdymercury left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a minor comment on the corner case.

Also, does this change with the cache maybe impact https://its.cern.ch/jira/browse/ROOT-7973 ?

@@ -30,7 +30,7 @@ TChainElement::TChainElement() : TNamed(),fBaddress(nullptr),fBaddressType(0),
{
fNPackets = 0;
fPackets = nullptr;
fEntries = 0;
fEntries = TTree::kMaxEntries;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this maybe be kMaxEntries+1 ?
Since otherwise kMaxEntries can not be safely reached?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression in 6.34: segfault when using TTreeReader on partially initialized TChain
3 participants