I’m having problems accessing an std::vector in a TTree. I enclose the code in question. The compilation goes like:
[code]COMPFLAGS = -g -Wall -fPIC -I$(shell root-config --incdir)
LINKS = $(shell root-config --glibs)
mytest: mytest.o
g++ (LINKS) -o @ $^
mytest.o: mytest.cpp
g++ -c (COMPFLAGS) ^
[/code]
Now, the program loads an TTree, loops over the entries and prints out the total number of jets. However, if I just execute the program I see this crash:
Warning in <TClass::TClass>: no dictionary for class AttributeListLayout is available
Warning in <TClass::TClass>: no dictionary for class pair<string,string> is available
*** Break *** bus error
/Users/rasmack/root/8151: No such file or directory.
Attaching to process 8151.
Reading symbols for shared libraries . done
Reading symbols for shared libraries ....................... done
0x91c9df69 in wait4 ()
========== STACKS OF ALL THREADS ==========
Thread 1 (process 8151 thread 0x10b):
#0 0x91c9df69 in wait4 ()
#1 0x91c9babc in system$UNIX2003 ()
#2 0x0088a181 in TUnixSystem::StackTrace ()
#3 0x0088e3c5 in TUnixSystem::DispatchSignals ()
#4 0x0088e538 in SigHandler ()
#5 <signal handler called>
#6 0x02be1c2a in std::vector<double, std::allocator<double> >::erase ()
#7 0x02ce0091 in ROOT::TCollectionProxyInfo::Type<std::vector<double, std::allocator<double> > >::clear ()
#8 0x0141df15 in TGenCollectionStreamer::Streamer ()
#9 0x013fabad in TCollectionStreamer::Streamer ()
#10 0x013fb19a in TCollectionClassStreamer::operator() ()
#11 0x0086adfd in TClass::Streamer ()
#12 0x013f2ce6 in TBufferFile::ReadFastArray ()
#13 0x0146b38d in TStreamerInfo::ReadBuffer<char**> ()
#14 0x01c3a20d in TBranchElement::ReadLeaves ()
#15 0x01c2c926 in TBranch::GetEntry ()
#16 0x01c35e44 in TBranchElement::GetEntry ()
#17 0x01c6d82c in TTree::GetEntry ()
#18 0x00002b20 in main () at mytest.cpp:26
The offending line appears to be the GetEntry line.
Running the program from inside gdb, now, yields a completely different result:
(gdb) r
Starting program: /Users/rasmack/root/mytest
Reading symbols for shared libraries +++++++++++++++++. done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Warning in <TClass::TClass>: no dictionary for class AttributeListLayout is available
Warning in <TClass::TClass>: no dictionary for class pair<string,string> is available
36
Program exited normally.
(gdb)
My conclusion is that the dynamic linking must be done differently when running in gdb. I just can’t figure out how to fix it. Does anyone have insights to offer?
Root version is 5.18. gcc is 4.0.1. I also enclose the root file with the TTree to demonstrate that it is readable and browseable.
AnalysisSkeleton.aan.root (10.4 KB)
mytest.cpp (549 Bytes)