Skip to content

Commit

Permalink
[tree] raise error instead of crash when trying to access null GetTree
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdymercury authored and pcanal committed May 8, 2024
1 parent 37f978c commit 949e490
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions tree/treeplayer/src/TTreeFormula.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3752,8 +3752,13 @@ const char* TTreeFormula::EvalStringInstance(Int_t instance)
if (fNeedLoading) { \
fNeedLoading = false; \
TBranch *br = leaf->GetBranch(); \
Long64_t tentry = br->GetTree()->GetReadEntry(); \
R__LoadBranch(br,tentry,fQuickLoad); \
if (br && br->GetTree()) { \
Long64_t tentry = br->GetTree()->GetReadEntry(); \
R__LoadBranch(br,tentry,fQuickLoad); \
} else { \
Error("TTreeFormula::TT_EVAL_INIT", \
"Could not init branch associated to this leaf (%s).", leaf->GetName()); \

Check warning on line 3760 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / mac14 ARM64 LLVM_ENABLE_ASSERTIONS=On, CMAKE_CXX_STANDARD=20

backslash and newline separated by space [-Wbackslash-newline-escape]

Check warning on line 3760 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / mac13 ARM64 LLVM_ENABLE_ASSERTIONS=On

backslash and newline separated by space [-Wbackslash-newline-escape]

Check warning on line 3760 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / mac-beta ARM64 LLVM_ENABLE_ASSERTIONS=On, CMAKE_CXX_STANDARD=20

backslash and newline separated by space [-Wbackslash-newline-escape]

Check warning on line 3760 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / alma8 LLVM_ENABLE_ASSERTIONS=On

backslash and newline separated by space

Check warning on line 3760 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / ubuntu20 LLVM_ENABLE_ASSERTIONS=On

backslash and newline separated by space

Check warning on line 3760 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / ubuntu22 imt=Off, LLVM_ENABLE_ASSERTIONS=On, CMAKE_BUILD_TYPE=Debug

backslash and newline separated by space

Check warning on line 3760 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / alma9 LLVM_ENABLE_ASSERTIONS=On, CMAKE_BUILD_TYPE=Debug

backslash and newline separated by space

Check warning on line 3760 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / run_nightlies / mac14 ARM64 LLVM_ENABLE_ASSERTIONS=On, CMAKE_CXX_STANDARD=20

backslash and newline separated by space [-Wbackslash-newline-escape]

Check warning on line 3760 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / run_nightlies / mac13 ARM64 LLVM_ENABLE_ASSERTIONS=On

backslash and newline separated by space [-Wbackslash-newline-escape]

Check warning on line 3760 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / run_nightlies / alma8 LLVM_ENABLE_ASSERTIONS=On

backslash and newline separated by space

Check warning on line 3760 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / run_nightlies / alma9 LLVM_ENABLE_ASSERTIONS=On, CMAKE_BUILD_TYPE=Debug

backslash and newline separated by space

Check warning on line 3760 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / run_nightlies / ubuntu20 LLVM_ENABLE_ASSERTIONS=On

backslash and newline separated by space

Check warning on line 3760 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / run_nightlies / fedora39 LLVM_ENABLE_ASSERTIONS=On, CMAKE_CXX_STANDARD=20

backslash and newline separated by space

Check warning on line 3760 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / run_nightlies / ubuntu22 imt=Off, LLVM_ENABLE_ASSERTIONS=On, CMAKE_BUILD_TYPE=Debug

backslash and newline separated by space

Check warning on line 3760 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / run_nightlies / ubuntu2310 LLVM_ENABLE_ASSERTIONS=On, CMAKE_CXX_STANDARD=20

backslash and newline separated by space
} \
} \
\
if (fAxis) { \
Expand Down Expand Up @@ -3792,21 +3797,36 @@ const char* TTreeFormula::EvalStringInstance(Int_t instance)
if (willLoad) { \
TBranch *branch = (TBranch*)fBranches.UncheckedAt(code); \
if (branch) { \
Long64_t treeEntry = branch->GetTree()->GetReadEntry(); \
R__LoadBranch(branch,treeEntry,fQuickLoad); \
if (branch->GetTree()) { \
Long64_t treeEntry = branch->GetTree()->GetReadEntry(); \
R__LoadBranch(branch,treeEntry,fQuickLoad); \
} else { \
Error("TTreeFormula::TT_EVAL_INIT_LOOP", \
"Could not init branch associated to this leaf (%s).", leaf->GetName()); \
} \
} else if (fDidBooleanOptimization) { \
branch = leaf->GetBranch(); \
Long64_t treeEntry = branch->GetTree()->GetReadEntry(); \
if (branch->GetReadEntry() != treeEntry) branch->GetEntry( treeEntry ); \
if (branch->GetTree()) { \
Long64_t treeEntry = branch->GetTree()->GetReadEntry(); \
if (branch->GetReadEntry() != treeEntry) branch->GetEntry( treeEntry ); \
} else { \
Error("TTreeFormula::TT_EVAL_INIT_LOOP", \
"Could not init branch associated to this leaf (%s).", leaf->GetName()); \
} \
} \
} else { \
/* In the cases where we are behind (i.e. right of) a potential boolean optimization \
this tree variable reading may have not been executed with instance==0 which would \
result in the branch being potentially not read in. */ \
if (fDidBooleanOptimization) { \
TBranch *br = leaf->GetBranch(); \
Long64_t treeEntry = br->GetTree()->GetReadEntry(); \
if (br->GetReadEntry() != treeEntry) br->GetEntry( treeEntry ); \
if (br->GetTree()) { \
Long64_t treeEntry = br->GetTree()->GetReadEntry(); \
if (br->GetReadEntry() != treeEntry) br->GetEntry( treeEntry ); \
} else { \
Error("TTreeFormula::TT_EVAL_INIT_LOOP", \
"Could not init branch associated to this leaf (%s).", leaf->GetName()); \
} \

Check warning on line 3829 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / mac14 ARM64 LLVM_ENABLE_ASSERTIONS=On, CMAKE_CXX_STANDARD=20

backslash and newline separated by space [-Wbackslash-newline-escape]

Check warning on line 3829 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / mac13 ARM64 LLVM_ENABLE_ASSERTIONS=On

backslash and newline separated by space [-Wbackslash-newline-escape]

Check warning on line 3829 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / mac-beta ARM64 LLVM_ENABLE_ASSERTIONS=On, CMAKE_CXX_STANDARD=20

backslash and newline separated by space [-Wbackslash-newline-escape]

Check warning on line 3829 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / alma8 LLVM_ENABLE_ASSERTIONS=On

backslash and newline separated by space

Check warning on line 3829 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / ubuntu20 LLVM_ENABLE_ASSERTIONS=On

backslash and newline separated by space

Check warning on line 3829 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / ubuntu22 imt=Off, LLVM_ENABLE_ASSERTIONS=On, CMAKE_BUILD_TYPE=Debug

backslash and newline separated by space

Check warning on line 3829 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / alma9 LLVM_ENABLE_ASSERTIONS=On, CMAKE_BUILD_TYPE=Debug

backslash and newline separated by space

Check warning on line 3829 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / run_nightlies / mac14 ARM64 LLVM_ENABLE_ASSERTIONS=On, CMAKE_CXX_STANDARD=20

backslash and newline separated by space [-Wbackslash-newline-escape]

Check warning on line 3829 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / run_nightlies / mac13 ARM64 LLVM_ENABLE_ASSERTIONS=On

backslash and newline separated by space [-Wbackslash-newline-escape]

Check warning on line 3829 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / run_nightlies / alma8 LLVM_ENABLE_ASSERTIONS=On

backslash and newline separated by space

Check warning on line 3829 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / run_nightlies / alma9 LLVM_ENABLE_ASSERTIONS=On, CMAKE_BUILD_TYPE=Debug

backslash and newline separated by space

Check warning on line 3829 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / run_nightlies / ubuntu20 LLVM_ENABLE_ASSERTIONS=On

backslash and newline separated by space

Check warning on line 3829 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / run_nightlies / fedora39 LLVM_ENABLE_ASSERTIONS=On, CMAKE_CXX_STANDARD=20

backslash and newline separated by space

Check warning on line 3829 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / run_nightlies / ubuntu22 imt=Off, LLVM_ENABLE_ASSERTIONS=On, CMAKE_BUILD_TYPE=Debug

backslash and newline separated by space

Check warning on line 3829 in tree/treeplayer/src/TTreeFormula.cxx

View workflow job for this annotation

GitHub Actions / run_nightlies / ubuntu2310 LLVM_ENABLE_ASSERTIONS=On, CMAKE_CXX_STANDARD=20

backslash and newline separated by space
} \
} \
if (real_instance>=fNdata[code]) return 0;
Expand Down

0 comments on commit 949e490

Please sign in to comment.