A TTree with a friend TChain doesn't propagate all errors happening in the chain
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Start with the friend-loading block in TTree::GetEntry (tree/tree/src/TTree.cxx), where the return value of LoadTreeFriend is checked, and with TTree::LoadTreeFriend itself. Build the reproducer root_friend_missing_file_bug.C from the issue, which uses a TChain friend pointing to a missing file. Done means events.GetEntry(0) returns a negative value on that failure, and the return-code convention for missing entries (-2) is kept. The sign and value conventions need a maintainer decision first.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Check duplicate issues.
- Checked for duplicates
Description
When a TTree has a friend TChain, the tree's GetEntry() does not return an error if the chain encounters one. This is caused by code in TTree::GetEntry(), which fails to return forward failures signaled by LoadTreeFriend():
if ( t->LoadTreeFriend(entry,this) >= 0 ) { // Returns < 0 on error
nb = t->GetEntry(t->GetReadEntry(),getall);
} else nb = 0; // Error path; I think this should be -1 for `LoadTreeFriend` errors except on missing entries (-2)
}
if (nb < 0) return nb; // Zero is rightfully not an error: it appears when no branch in the friend is enabled
The important point for reproduction is to make LoadTreeFriend fail. With TChain, this is trivially achieved with a file that cannot be loaded or doesn't contain the input tree. With TTree, this is only potentially possible in a very contrived scenario with friends of friends and a custom fNotify.
Reproducer
Run with root -l -q root_friend_missing_file_bug.C.
#include <TChain.h>
#include <TFile.h>
#include <TTree.h>
#include <stdio.h>
void root_friend_missing_file_bug()
{
// Setup: 1-event main file
{
TFile f("main.root", "RECREATE");
TTree t("events", "events");
int x = 0;
t.Branch("x", &x);
t.Fill();
f.Write();
}
TFile f("main.root", "READ");
auto &events = *f.Get<TTree>("events"); // Repro also works with a TChain here
TChain corrections("aux");
corrections.Add("/ThisFileDoesNotExist.root");
// Repro also works with branches in corrections
events.AddFriend(&corrections);
// The tree returns 4, i.e., doesn't report the missing file.
printf("events.GetEntry(0) = %d (failure if <= 0)\n", events.GetEntry(0));
// The chain does return an error-ish value (0, inconsistent with the TTree API that
// would return -1, but changing it would be a breaking change).
printf("corrections.GetEntry(0) = %d (failure if <= 0)\n", corrections.GetEntry(0));
}
ROOT version
6.38.00, but code confirmed identical in master.
------------------------------------------------------------------
| Welcome to ROOT 6.38.00 https://root.cern |
| (c) 1995-2025, The ROOT Team; conception: R. Brun, F. Rademakers |
| Built for linuxx8664gcc on Feb 03 2026, 21:14:06 |
| From tags/6-38-00@6-38-00 |
| With g++ (GCC) 15.2.0 std202302 |
| Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------------
Installation method
LCG 109
Operating system
lxplus
Additional context
I wanted to identify the origin of errors and handle them appropriately based on their category (unrecoverable tree/file not found vs transient network issues for which a retry can work).
Full disclosure: this bug was found and investigated with the help of AI. I take full responsibility for the report.
- Lingua principale
- C++
- Stelle
- 3.3k
- Fork
- 1.6k
- Merge medio
- 2g 10h
- PR unite (30g)
- 200
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di root-project/root
-
thisroot.sh: wrong ROOTSYS in zsh when the shell's command line has a newlineForse già presa @dpiparo l’ha presa 14 giorni fa. Apertabug in:Build System
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
root-project/root#23746 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[Build] `fail-on-missing` contract not respected for `NOT http AND webgui`Forse già presa @guitargeek l’ha presa 3 giorni fa. Apertabug in:Build System
root-project/root#23907 · 3 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Header cleanup campaignForse già presa @hageboeck l’ha presa 4 giorni fa. Apertaimprovement in:Core Libraries
root-project/root#23880 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
TDataMember::GetOffset interfers to TDataMember::GetOffsetCintForse già presa @pcanal l’ha presa 11 giorni fa. Apertabug in:Core Libraries
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
root-project/root#23777 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
`TChain::GetEntries` internal caching ineffective?Forse già presa @pcanal l’ha presa 17 giorni fa. Apertaimprovement in:TTree
root-project/root#23738 · 6 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di root-project/root
Issue simili
-
Issue-Bug Needs-Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
microsoft/winget-cli#6645 ·
I maintainer di solito rispondono entro 2 giorni
-
cleanup help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
ESPresense/ESPresense#2602 ·
I maintainer di solito rispondono entro 1 giorno
-
devex good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
artifact:simulation-scenario domain:physics good first issue help wanted role:validation testing
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 3 giorni