Hi every-one.
I am developping a graphical user interface for allowing people non familiar wit the root interface to make their own graphs from the data of a TTree sotred in au *.root file.
The goal is too make a autonomous executable after compilation and not to make macro to be executed in a root CINT
Inside my progamm i have encounter problem when reading my tree. In order to isolate the probleme i have written this little code
#include <TFile.h>
#include <TTree.h>
#include <iostream>
#include "../source/include/CLASSHeaders.hxx"
using namespace std;
int main(){
TFile *RootFile=new TFile("UOXscenario.root");
TTree *tree;
RootFile->GetObject("Data",tree);
Int_t nentries = tree->GetEntries();
cout<<"nentries : "<<nentries<<endl;
IsotopicVector *ReadIsotopicVector;
tree->SetBranchStatus("TOTAL.",1);
tree->SetBranchAddress("TOTAL.", &ReadIsotopicVector);
vector<double> vZAIQ;
cout<<"just before the for"<<endl;
for(int i=0;i<nentries;i++){
tree->GetEntry(i);
double IsotopicQuantity=ReadIsotopicVector->GetZAIIsotopicQuantity(94,239,0);
cout<<" IsotopicQuantity : "<<IsotopicQuantity<<endl;
vZAIQ.push_back(IsotopicQuantity*1./6.02e23);
}
for(unsigned int i=0;i<vZAIQ.size();i++){
cout<<"vZAIQ : "<<vZAIQ[i]<<endl;
}
}
The Isotopicvector is an object created and defind in CLASSHeader.hxx
After compilation i checked the linkage of all my library
linux-vdso.so.1 => (0x00007fff9a3ff000)
libCLASSpkg.so => /projet/CLASS/lib/libCLASSpkg.so (0x00002b4dc580f000)
libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x00002b4dc5af8000)
libCore.so => /usr/physics/root/root_v5.34.00/lib/libCore.so (0x00002b4dc5d06000)
libRIO.so => /usr/physics/root/root_v5.34.00/lib/libRIO.so (0x00002b4dc66cb000)
libHist.so => /usr/physics/root/root_v5.34.00/lib/libHist.so (0x00002b4dc6ae6000)
libTree.so => /usr/physics/root/root_v5.34.00/lib/libTree.so (0x00002b4dc7207000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00002b4dc763c000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00002b4dc793d000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00002b4dc7b53000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00002b4dc7f12000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00002b4dc820f000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00002b4dc842c000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00002b4dc8634000)
libCint.so => /usr/physics/root/root_v5.34.00/lib/libCint.so (0x00002b4dc884c000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00002b4dc91d3000)
libThread.so => /usr/physics/root/root_v5.34.00/lib/libThread.so (0x00002b4dc93d7000)
libMatrix.so => /usr/physics/root/root_v5.34.00/lib/libMatrix.so (0x00002b4dc962c000)
libMathCore.so => /usr/physics/root/root_v5.34.00/lib/libMathCore.so (0x00002b4dc9a85000)
libNet.so => /usr/physics/root/root_v5.34.00/lib/libNet.so (0x00002b4dc9eb9000)
/lib64/ld-linux-x86-64.so.2 (0x00002b4dc55ea000)
libcrypto.so.1.0.0 => /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (0x00002b4dca23a000)
libssl.so.1.0.0 => /lib/x86_64-linux-gnu/libssl.so.1.0.0 (0x00002b4dca615000)
All seems to be OK
And i run my program :
nentries : 602
just before the for
*** Break *** segmentation violation
===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0 0x00002b139c7a344e in __libc_waitpid (pid=<optimized out>, stat_loc=0x7fffa0768200, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:32
#1 0x00002b139c72929e in do_system (line=0x2088890 "/usr/physics/root/root_v5.34.00/etc/gdb-backtrace.sh 17816 1>&2") at ../sysdeps/posix/system.c:149
#2 0x00002b139aaece47 in TUnixSystem::StackTrace() () from /usr/physics/root/root_v5.34.00/lib/libCore.so
#3 0x00002b139aaef723 in TUnixSystem::DispatchSignals(ESignals) () from /usr/physics/root/root_v5.34.00/lib/libCore.so
#4 <signal handler called>
#5 0x00002b139b2c517c in TBufferFile::ReadUInt(unsigned int&) () from /usr/physics/root/root_v5.34.00/lib/libRIO.so
#6 0x00002b139b309a04 in int TStreamerInfoActions::ReadBasicType<unsigned int>(TBuffer&, void*, TStreamerInfoActions::TConfiguration const*) () from /usr/physics/root/root_v5.34.00/lib/libRIO.so
#7 0x00002b139b2c0ba5 in TBufferFile::ApplySequence(TStreamerInfoActions::TActionSequence const&, void*) () from /usr/physics/root/root_v5.34.00/lib/libRIO.so
#8 0x00002b139be31b38 in TBranchElement::ReadLeavesMember(TBuffer&) () from /usr/physics/root/root_v5.34.00/lib/libTree.so
#9 0x00002b139be3053f in TBranch::GetEntry(long long, int) () from /usr/physics/root/root_v5.34.00/lib/libTree.so
#10 0x00002b139be3ae70 in TBranchElement::GetEntry(long long, int) () from /usr/physics/root/root_v5.34.00/lib/libTree.so
#11 0x00002b139be3ae2a in TBranchElement::GetEntry(long long, int) () from /usr/physics/root/root_v5.34.00/lib/libTree.so
#12 0x00002b139be3ae2a in TBranchElement::GetEntry(long long, int) () from /usr/physics/root/root_v5.34.00/lib/libTree.so
#13 0x00002b139be79b8c in TTree::GetEntry(long long, int) () from /usr/physics/root/root_v5.34.00/lib/libTree.so
#14 0x00000000004012c4 in main () at TestTTree.cxx:22
===========================================================
And now comes the bug