Cannot use GetEntry with g++

Hi,

I’m having a strange problem when trying to compile a code with g++ and more specifically to use “->GetEntry(i);”. The program compiles fine with aclic but when I try to use g++ I just can’t use the method. Since it compiles in aclic, it indicates that is some dictionary/library linking problem of some sort but I tried every trick I know and it was in vain. Perhaps something missing in my LinkDef.h but this too led nowhere until now. The program, Makefile and Linkdef.h file are enclosed. The crash occurs in line 63 of cutflow.cpp. I confirmed the problem is there by using gdb. The relevant files are all enclosed. The entire stack is:

%S[%m]%s %~ %# ./Skeleton
Warning in TClass::TClass: no dictionary for class AttributeListLayout is available

*** Break *** segmentation violation

===========================================================
There was a crash.
This is the entire stack trace of all threads:

#0 0x00002b9a243e94d5 in waitpid () from /lib64/libc.so.6
#1 0x00002b9a2438b481 in do_system () from /lib64/libc.so.6
#2 0x00002b9a1e795a96 in TUnixSystem::StackTrace() ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.32.01/x86_64-slc5-gcc43-opt/root/lib/libCore.so
#3 0x00002b9a1e79536c in TUnixSystem::DispatchSignals(ESignals) ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.32.01/x86_64-slc5-gcc43-opt/root/lib/libCore.so
#4
#5 0x00002b9a1fb6ef58 in TBufferFile::ReadFastArray(int*, int) ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.32.01/x86_64-slc5-gcc43-opt/root/lib/libRIO.so
#6 0x00002b9a1fbaa64f in void TGenCollectionStreamer::ReadBufferVectorPrimitives(TBuffer&, void*) ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.32.01/x86_64-slc5-gcc43-opt/root/lib/libRIO.so
#7 0x00002b9a1fb74745 in TBufferFile::ReadFastArray(void*, TClass const*, int, TMemberStreamer*, TClass const*) ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.32.01/x86_64-slc5-gcc43-opt/root/lib/libRIO.so
#8 0x00002b9a1fbc2bfe in int TStreamerInfoActions::ReadSTL<&(TStreamerInfoActions::ReadSTLMemberWiseSameClass(TBuffer&, void*, TStreamerInfoActions::TConfiguration const*, short)), &(TStreamerInfoActions::ReadSTLObjectWiseFastArray(TBuffer&, void*, TStreamerInfoActions::TConfiguration const*, short, unsigned int))>(TBuffer&, void*, TStreamerInfoActions::TConfiguration const*) ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.32.01/x86_64-slc5-gcc43-opt/root/lib/libRIO.so
#9 0x00002b9a1fb6f31d in TBufferFile::ApplySequence(TStreamerInfoActions::TActionSequence const&, void*) ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.32.01/x86_64-slc5-gcc43-opt/root/lib/libRIO.so
#10 0x00002b9a213d4221 in TBranchElement::ReadLeavesMember(TBuffer&) ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.32.01/x86_64-slc5-gcc43-opt/root/lib/libTree.so
#11 0x00002b9a213c5a56 in TBranch::GetEntry(long long, int) ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.32.01/x86_64-slc5-gcc43-opt/root/lib/libTree.so
#12 0x00002b9a213ce7d6 in TBranchElement::GetEntry(long long, int) ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.32.01/x86_64-slc5-gcc43-opt/root/lib/libTree.so
#13 0x00002b9a2141c8b0 in TTree::GetEntry(long long, int) ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.32.01/x86_64-slc5-gcc43-opt/root/lib/libTree.so
#14 0x000000000040306e in main () at cutflow.cpp:63

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 0x00002b9a1fb6ef58 in TBufferFile::ReadFastArray(int*, int) ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.32.01/x86_64-slc5-gcc43-opt/root/lib/libRIO.so
#6 0x00002b9a1fbaa64f in void TGenCollectionStreamer::ReadBufferVectorPrimitives(TBuffer&, void*) ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.32.01/x86_64-slc5-gcc43-opt/root/lib/libRIO.so
#7 0x00002b9a1fb74745 in TBufferFile::ReadFastArray(void*, TClass const*, int, TMemberStreamer*, TClass const*) ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.32.01/x86_64-slc5-gcc43-opt/root/lib/libRIO.so
#8 0x00002b9a1fbc2bfe in int TStreamerInfoActions::ReadSTL<&(TStreamerInfoActions::ReadSTLMemberWiseSameClass(TBuffer&, void*, TStreamerInfoActions::TConfiguration const*, short)), &(TStreamerInfoActions::ReadSTLObjectWiseFastArray(TBuffer&, void*, TStreamerInfoActions::TConfiguration const*, short, unsigned int))>(TBuffer&, void*, TStreamerInfoActions::TConfiguration const*) ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.32.01/x86_64-slc5-gcc43-opt/root/lib/libRIO.so
#9 0x00002b9a1fb6f31d in TBufferFile::ApplySequence(TStreamerInfoActions::TActionSequence const&, void*) ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.32.01/x86_64-slc5-gcc43-opt/root/lib/libRIO.so
#10 0x00002b9a213d4221 in TBranchElement::ReadLeavesMember(TBuffer&) ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.32.01/x86_64-slc5-gcc43-opt/root/lib/libTree.so
#11 0x00002b9a213c5a56 in TBranch::GetEntry(long long, int) ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.32.01/x86_64-slc5-gcc43-opt/root/lib/libTree.so
#12 0x00002b9a213ce7d6 in TBranchElement::GetEntry(long long, int) ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.32.01/x86_64-slc5-gcc43-opt/root/lib/libTree.so
#13 0x00002b9a2141c8b0 in TTree::GetEntry(long long, int) ()
from /afs/cern.ch/sw/lcg/app/releases/ROOT/5.32.01/x86_64-slc5-gcc43-opt/root/lib/libTree.so
#14 0x000000000040306e in main () at cutflow.cpp:63

[…] $ ./Skeleton
Error in TFile::TFile: file /tmp/bmeirose/MC/AF2/NTUP_SUSY.765773._000001.root does not exist
vx_nTracks->size() = 4261115515
Events before 0
Prim. vertex 0

Sorry, forgot to mention I’m running in lxplus419, the file is there.

[quote]it indicates that is some dictionary/library linking problem of some sort but I tried every trick I know and it was in vain. [/quote]Those are likely to indicate that you have not loaded all the required library and/or have not initialized the autoloader. For example you might want to create a TApplication object in your main.

Cheers,
Philippe.

Hi,

thanks. I’m not sure why would I need a TApplication for. I saw in several other posts that you recommend it when using makefile etc, but how to use it in general is not entirely clear to me. I understand one should do something like

TApplication theApp(“App”, &arg1, arg2); but where would one need these arguments for? I’m making this rather general newbie question to try to avoid future problems of not using a strictly correct structure. Perhaps you could point out a good example?

In any case, in my program the problem was however much more simple. I forgot to initialize a vector and aclic ignores the error (assume is zero) but g++ correctly assumes nothing at all and so GetEntry crashes.

Hi,

The suggestion about TApplication was based on the fact that some library might not have been properly loaded. To solve such a ‘missing’ library issue, there is 2 possible solutions, either explicitly link against the library or insure that ROOT automatic loader is properly initialized (which a TApplication does). The argument to TApplication are supposed to be directly derived from the argument to the main routine (which signature should be: int main(int argc, char **argc) ).

Cheers,
Philippe.