Skip to content

Commit

Permalink
[tree] Always inform index formulas about changed tree in friend chain
Browse files Browse the repository at this point in the history
To avoid following valgrind error leading to crashes in multithreaded RDF runs:

```
==735217== Invalid read of size 8
==735217==    at 0x6A4517F: TTreeFormula::UpdateFormulaLeaves() (TTreeFormula.cxx:5121)
==735217==    by 0x6A5B9AF: TTreeIndex::UpdateFormulaLeaves(TTree const*) (TTreeIndex.cxx:625)
==735217==    by 0x67A5447: TChain::LoadTree(long long) (TChain.cxx:1670)
==735217==    by 0x6A94DBD: TTreeReader::SetEntryBase(long long, bool) (TTreeReader.cxx:669)
==735217==    by 0x6A96027: TTreeReader::SetEntry(long long) (TTreeReader.h:225)
==735217==    by 0x7576BAA: TTreeReader::Next() (TTreeReader.h:217)
==735217==    by 0x756D591: (anonymous namespace)::validTTreeReaderRead(TTreeReader&) (RLoopManager.cxx:538)
==735217==    by 0x756D9A9: ROOT::Detail::RDF::RLoopManager::RunTreeProcessorMT()::{lambda(TTreeReader&)#1}::operator()(TTreeReader&) const (RLoopManager.cxx:575)
==735217==    by 0x7574F7E: void std::__invoke_impl<void, ROOT::Detail::RDF::RLoopManager::RunTreeProcessorMT()::{lambda(TTreeReader&)#1}&, TTreeReader&>(std::__invoke_other, ROOT::Detail::RDF::RLoopManager::RunTreeProcessorMT()::{lambda(TTreeReader&)#1}&, TTreeReader&) (invoke.h:61)
==735217==    by 0x757480E: std::enable_if<is_invocable_r_v<void, ROOT::Detail::RDF::RLoopManager::RunTreeProcessorMT()::{lambda(TTreeReader&)#1}&, TTreeReader&>, void>::type std::__invoke_r<void, ROOT::Detail::RDF::RLoopManager::RunTreeProcessorMT()::{lambda(TTreeReader&)#1}&, TTreeReader&>(ROOT::Detail::RDF::RLoopManager::RunTreeProcessorMT()::{lambda(TTreeReader&)#1}&, TTreeReader&) (invoke.h:111)
==735217==    by 0x757433A: std::_Function_handler<void (TTreeReader&), ROOT::Detail::RDF::RLoopManager::RunTreeProcessorMT()::{lambda(TTreeReader&)#1}>::_M_invoke(std::_Any_data const&, TTreeReader&) (std_function.h:290)
==735217==    by 0x6ABCE3E: std::function<void (TTreeReader&)>::operator()(TTreeReader&) const (std_function.h:591)
==735217==  Address 0x15b4e000 is 0 bytes inside a block of size 712 free'd
==735217==    at 0x48456C6: operator delete(void*) (vg_replace_malloc.c:1131)
==735217==    by 0x4E9494B: TStorage::ObjectDealloc(void*) (TStorage.cxx:325)
==735217==    by 0x4E6B181: TObject::operator delete(void*) (TObject.cxx:1113)
==735217==    by 0x67F47E9: TTree::~TTree() (TTree.cxx:1023)
==735217==    by 0x4EED8F1: TCollection::GarbageCollect(TObject*) (TCollection.cxx:736)
==735217==    by 0x4EF5D4C: TList::Delete(char const*) (TList.cxx:535)
==735217==    by 0x4EF0428: THashList::Delete(char const*) (THashList.cxx:215)
==735217==    by 0x5507848: TDirectoryFile::Close(char const*) (TDirectoryFile.cxx:585)
==735217==    by 0x5523835: TFile::Close(char const*) (TFile.cxx:986)
==735217==    by 0x5521226: TFile::~TFile() (TFile.cxx:563)
==735217==    by 0x55215FF: TFile::~TFile() (TFile.cxx:600)
==735217==    by 0x67A4990: TChain::LoadTree(long long) (TChain.cxx:1490)
==735217==  Block was alloc'd at
==735217==    at 0x4841FEC: operator new(unsigned long) (vg_replace_malloc.c:487)
==735217==    by 0x4E948DF: TStorage::ObjectAlloc(unsigned long) (TStorage.cxx:293)
==735217==    by 0x48C648E: TObject::operator new(unsigned long) (TObject.h:181)
==735217==    by 0x672E04D: ROOT::new_TTree(void*) (G__Tree.cxx:4363)
==735217==    by 0x4F4AA25: TClass::NewObject(TClass::ENewType, bool) const (TClass.cxx:5084)
==735217==    by 0x4F4A932: TClass::New(TClass::ENewType, bool) const (TClass.cxx:5061)
==735217==    by 0x556146A: TKey::ReadObj() (TKey.cxx:809)
==735217==    by 0x55091D3: TDirectoryFile::Get(char const*) (TDirectoryFile.cxx:988)
==735217==    by 0x67A4CA4: TChain::LoadTree(long long) (TChain.cxx:1542)
==735217==    by 0x6A94DBD: TTreeReader::SetEntryBase(long long, bool) (TTreeReader.cxx:669)
==735217==    by 0x6A96027: TTreeReader::SetEntry(long long) (TTreeReader.h:225)
==735217==    by 0x6A94855: TTreeReader::SetEntriesRange(long long, long long) (TTreeReader.cxx:560)
```
  • Loading branch information
vepadulano authored and dpiparo committed Dec 26, 2024
1 parent 0f6c709 commit cddab85
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tree/tree/src/TChain.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1667,7 +1667,7 @@ Long64_t TChain::LoadTree(Long64_t entry)
TTree* t = fe->GetTree();
if (!t) continue;
if (t->GetTreeIndex()) {
t->GetTreeIndex()->UpdateFormulaLeaves(nullptr);
t->GetTreeIndex()->UpdateFormulaLeaves(GetTree());
}
if (t->GetTree() && t->GetTree()->GetTreeIndex()) {
t->GetTree()->GetTreeIndex()->UpdateFormulaLeaves(GetTree());
Expand Down

0 comments on commit cddab85

Please sign in to comment.