Skip to content

[core] Query TRefTable before TProcessID in TRefArray lookups#22771

Open
guitargeek wants to merge 1 commit into
root-project:masterfrom
guitargeek:ROOT-3594
Open

[core] Query TRefTable before TProcessID in TRefArray lookups#22771
guitargeek wants to merge 1 commit into
root-project:masterfrom
guitargeek:ROOT-3594

Conversation

@guitargeek

Copy link
Copy Markdown
Contributor

Fixes ROOT-3594 (https://its.cern.ch/jira/browse/ROOT-3594).

Follows up on previous attempts:

TRefArray::At() and operator[] looked up the referenced object in the TProcessID first and only consulted the TRefTable when nothing was found. When entries of a TTree are read selectively (as TTree::Draw and TTree::Scan do), an object from a previously read entry can still be registered under the same UID, so the lookup silently returned a stale object instead of triggering the TBranchRef auto-load of the referenced branch for the current entry.

Invert the order in At(), operator[], First(), Last(), After() and Before(): query the TRefTable first, which lets TBranchRef load the referenced branch at the requested entry, and only then fall back to the plain TProcessID lookup. This matches what TRef::GetObject() has always done.

Add a regression test (TTreeRegressions.TRefArrayReadsCurrentEntry) that reads only the TRefArray branch of a second entry after fully loading the first one.

Update RefProxyTest.ref in roottest: its expected output encoded the bug. For the split2/split9 files, fHighPt.At(0) at entry 0 recorded the track values of the last previously loaded entry instead of entry 0, inconsistently with the split0/split1 sections which already showed the correct values. The new output is uniform across all split levels. Note that objects resolved through a TRefArray now consistently carry the PID-slot byte in the top byte of their in-memory fUniqueID, as objects resolved through a TRef already did; the masked UID (& 0xFFFFFF) is unchanged.

🤖 Done with the help of AI.

Comment thread tree/tree/test/TTreeRegressions.cxx
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

Test Results

    23 files      23 suites   3d 14h 40m 53s ⏱️
 3 872 tests  2 897 ✅   0 💤 975 ❌
78 787 runs  77 320 ✅ 490 💤 977 ❌

For more details on these failures, see this check.

Results for commit f382af0.

♻️ This comment has been updated with latest results.

Fixes ROOT-3594 (https://its.cern.ch/jira/browse/ROOT-3594).

`TRefArray::At()` and `operator[]` looked up the referenced object in
the TProcessID first and only consulted the TRefTable when nothing was
found. When entries of a TTree are read selectively (as TTree::Draw and
TTree::Scan do), an object from a previously read entry can still be
registered under the same UID, so the lookup silently returned a stale
object instead of triggering the TBranchRef auto-load of the referenced
branch for the current entry.

Invert the order in At(), operator[], First(), Last(), After() and
Before(): query the TRefTable first, which lets TBranchRef load the
referenced branch at the requested entry, and only then fall back to
the plain TProcessID lookup. This matches what TRef::GetObject() has
always done.

Add a regression test (TTreeRegressions.TRefArrayReadsCurrentEntry)
that reads only the TRefArray branch of a second entry after fully
loading the first one.

Update RefProxyTest.ref in roottest: its expected output encoded the
bug. For the split2/split9 files, fHighPt.At(0) at entry 0 recorded the
track values of the last previously loaded entry instead of entry 0,
inconsistently with the split0/split1 sections which already showed the
correct values. The new output is uniform across all split levels. Note
that objects resolved through a TRefArray now consistently carry the
PID-slot byte in the top byte of their in-memory fUniqueID, as objects
resolved through a TRef already did; the masked UID (`& 0xFFFFFF`) is
unchanged.

🤖 Done with the help of AI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants