Dear rooters,
I discovered the crash of the TTree::GetEntry() method in following conditionis:
-
ROOT 5.28.00
-
there is root-file, created and wroted using TFile
-
file contains Tree, which constructed using TTree and using object of My_Class in following manner:
…
My_Class* object_of_MyClass = new My_Class();
…
TTree* My_Tree = new TTree(“my_tree_name”,“meme”);
My_Tree->Branch(“my_branch_name”, &object_of_MyClass, 64000, 1);
for(…)
{
…
My_Tree->Fill();
My_Tree->Write();
…
}
… etc. -
Myclass contains fields
class MyClass : public TObject
{
…
private:
int a;
TH2D* My_Histogram;
…
ClassDef(…);
}
Thus, My_Tree contains branch of type TH2D* My_Histogram; -
there is the function(), which reads this file and this tree as following:
int my_reader_class::function()
{
My_Class* object_of_MyClass = new My_Class(); // empty constructor
…
TFile* pointer_to_file = new TFile(File_Name, “READ”);
…
TTree* My_Tree = (TTree*)pointer_to_file->Get(“my_tree_name”);
TBranch* bntrack1 = My_Tree->GetBranch(“my_branch_name”);
bntrack1->SetAddress(&object_of_MyClass);
My_Tree->GetEntry(33);
…
object_of_MyClass->Clear(); // TObject::Clear()
delete object_of_MyClass; // or TObject::Delete()
delete My_Tree; // or TTree::Delete("")
pointer_to_file->DeleteAll(); // TDirectory::DeleteAll()
pointer_to_file->Close(“R”);
delete pointer_to_file;return 0;
}
-
there is file main.C, containing function main(), which running function() twice:
#include …
int main()
{
my_reader_class* MRC = new my_reader_class();MRC->function(); // one MRC->function(); // two delete MRC; return 0;
}
- I use ROOT as the set of external libraries, what assumes compilation in following form:
i) rootcint -f my_reader_class_Dictionary.cxx -c my_reader_class.h
ii) g++ -shared -fPIC root-config --cflags
-o libmy_reader_class.so my_reader_class.C my_reader_class_Dictionary.cxx
iii) g++ -g -o0 -pthread -m64 -I/(path) -L/(path) -Wl,-rpath,/(path) -I/(ROOT includes) -L/(ROOT libraries) -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lGui -lTreePlayer -pthread -lm -ldl -rdynamic -lmy_reader_class main.C -o program_name
As the result, I can read entry number 33 first time, at the line which commented “//one”, even I can draw it to check that everything right. Everything is rigth. Entry number 33 contains exactly the histogram, which I have put to there before.
However, second time, at the line which commented “//two” I have the crash.
Crash at the start of GetEntry(33):
*** Break *** segmentation violation
===========================================================
There was a crash.
This is the entire stack trace of all threads:
#0 0x0000003b09098c05 in waitpid () from /lib64/libc.so.6
#1 0x0000003b0903c481 in do_system () from /lib64/libc.so.6
#2 0x00002ba55beddc6a in TUnixSystem::StackTrace() ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libCore.so
#3 0x00002ba55bedd63c in TUnixSystem::DispatchSignals(ESignals) ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libCore.so
#4
#5 0x00002ba55d8bc1f8 in ROOT::delete_TH1D(void*) ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libHist.so
#6 0x00002ba55bea7d57 in TClass::Destructor(void*, bool) ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libCore.so
#7 0x00002ba55cff2e3f in TBufferFile::ReadFastArray(void**, TClass const*, int, bool, TMemberStreamer*, TClass const*) ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libRIO.so
#8 0x00002ba55d09837c in int TStreamerInfo::ReadBuffer<char**>(TBuffer&, char** const&, int, int, int, int) ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libRIO.so
#9 0x00002ba55d028e6e in TStreamerInfoActions::GenericAction(TBuffer&, void*, TStreamerInfoActions::TConfiguration const*) ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libRIO.so
#10 0x00002ba55cfed44d in TBufferFile::ReadSequence(TStreamerInfoActions::TActionSequence const&, void*) ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libRIO.so
#11 0x00002ba55e7a4c19 in TBranchElement::ReadLeavesMember(TBuffer&) ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libTree.so
#12 0x00002ba55e79b215 in TBranch::GetEntry(long long, int) ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libTree.so
#13 0x00002ba55e7a2253 in TBranchElement::GetEntry(long long, int) ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libTree.so
#14 0x00002ba55e7a2216 in TBranchElement::GetEntry(long long, int) ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libTree.so
#15 0x00002ba55e7e73a0 in TTree::GetEntry(long long, int) ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libTree.so
#16 0x00002ba562c36912 in builder_class::reconstruction_reader() ()
from /grid_mnt/vol__vol1__u/llr/galop/seredov/Magnetic_Line/TREE_BUILDER/tree_builder_version_g++/libbuilder_class.so
#17 0x000000000040198d in main () at main.C:57
The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
#5 0x00002ba55d8bc1f8 in ROOT::delete_TH1D(void*) ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libHist.so
#6 0x00002ba55bea7d57 in TClass::Destructor(void*, bool) ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libCore.so
#7 0x00002ba55cff2e3f in TBufferFile::ReadFastArray(void**, TClass const*, int, bool, TMemberStreamer*, TClass const*) ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libRIO.so
#8 0x00002ba55d09837c in int TStreamerInfo::ReadBuffer<char**>(TBuffer&, char** const&, int, int, int, int) ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libRIO.so
#9 0x00002ba55d028e6e in TStreamerInfoActions::GenericAction(TBuffer&, void*, TStreamerInfoActions::TConfiguration const*) ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libRIO.so
#10 0x00002ba55cfed44d in TBufferFile::ReadSequence(TStreamerInfoActions::TActionSequence const&, void*) ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libRIO.so
#11 0x00002ba55e7a4c19 in TBranchElement::ReadLeavesMember(TBuffer&) ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libTree.so
#12 0x00002ba55e79b215 in TBranch::GetEntry(long long, int) ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libTree.so
#13 0x00002ba55e7a2253 in TBranchElement::GetEntry(long long, int) ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libTree.so
#14 0x00002ba55e7a2216 in TBranchElement::GetEntry(long long, int) ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libTree.so
#15 0x00002ba55e7e73a0 in TTree::GetEntry(long long, int) ()
from /opt/exp_soft/llr/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/lib/libTree.so
#16 0x00002ba562c36912 in builder_class::reconstruction_reader() ()
from /grid_mnt/vol__vol1__u/llr/galop/seredov/Magnetic_Line/TREE_BUILDER/tree_builder_version_g++/libbuilder_class.so
#17 0x000000000040198d in main () at main.C:57
What I am doing wrong?
Thanks in advance.