Dear rooters,
I have a problem reading an NTuple (http://cern.ch/ktoms/GenEff.ntup.root, 5MB), ROOT crashes with a segmentation violation.
The ROOT version is 6.11/02, tested locally and on the lxplus, same behavior. Tested with 6.10/06 as well.
The code is:
#include<vector>
#include<iostream>
#include<string>
#include"TTree.h"
#include"TInterpreter.h"
#include"TEventList.h"
#include"TH1D.h"
#include"TMath.h"
#include"TROOT.h"
#include"TFriendElement.h"
#include"TSystem.h"
#include"TVectorD.h"
#include"TFile.h"
#include"TNtuple.h"
using namespace std;
int test()
{
gROOT->ProcessLine("#include <vector>");
gInterpreter->GenerateDictionary("vector<vector<int> >","vector");
gInterpreter->GenerateDictionary("vector<vector<double> >","vector");
TFile *f = new TFile("GenEff.ntup.root");
TTree *bplus_ntuple = (TTree*)f->Get("TRUTHDECAY");
vector<vector<int> > * PDGid;
bplus_ntuple->SetBranchAddress("PDGid",&PDGid);
vector<vector<double> > * pt;
bplus_ntuple->SetBranchAddress("pt",&pt);
vector<vector<double> > * theta;
bplus_ntuple->SetBranchAddress("theta",&theta);
int max_entries=10;
for(int i=0; i < bplus_ntuple->GetEntries() && i<max_entries; i++)
{
cout << "Trying to get entry (" << i << ")" << endl;
gDebug=2;
bplus_ntuple->GetEntry(i); // <-- crash
}
return 0;
}
The output is:
root [0]
Processing test.cxx...
Trying to get entry (0)
Entry: 0, registering branch: eventNumber
Entry: 0, registering branch: runNumber
Entry: 0, registering branch: lumiBlock
Entry: 0, registering branch: decay
Entry: 0, registering branch: PDGid
Entry: 0, registering branch: mother
Entry: 0, registering branch: fdaughter
Entry: 0, registering branch: ldaughter
Entry: 0, registering branch: status
Entry: 0, registering branch: barcode
Entry: 0, registering branch: pt
Entry: 0, registering branch: theta
Entry: 0, registering branch: phi
Entry: 0, registering branch: pvx
Entry: 0, registering branch: pvy
Entry: 0, registering branch: pvz
Entry: 0, registering branch: mass
Entry: 0, registering baskets branch eventNumber, fEntryNext=100, fNseek=1, fNtotCurrentBuf=10828
Entry: 0, registering baskets branch runNumber, fEntryNext=100, fNseek=2, fNtotCurrentBuf=11100
Entry: 0, registering baskets branch lumiBlock, fEntryNext=100, fNseek=3, fNtotCurrentBuf=11398
Entry: 0, registering baskets branch decay, fEntryNext=100, fNseek=4, fNtotCurrentBuf=16888
Entry: 0, registering baskets branch PDGid, fEntryNext=100, fNseek=5, fNtotCurrentBuf=23250
Entry: 0, registering baskets branch mother, fEntryNext=100, fNseek=6, fNtotCurrentBuf=27448
Entry: 0, registering baskets branch fdaughter, fEntryNext=100, fNseek=7, fNtotCurrentBuf=32320
Entry: 0, registering baskets branch ldaughter, fEntryNext=100, fNseek=8, fNtotCurrentBuf=37196
Entry: 0, registering baskets branch status, fEntryNext=100, fNseek=9, fNtotCurrentBuf=40986
Entry: 0, registering baskets branch barcode, fEntryNext=100, fNseek=10, fNtotCurrentBuf=46571
Entry: 0, registering baskets branch pt, fEntryNext=100, fNseek=11, fNtotCurrentBuf=71642
Entry: 0, registering baskets branch theta, fEntryNext=100, fNseek=12, fNtotCurrentBuf=96964
Entry: 0, registering baskets branch phi, fEntryNext=100, fNseek=13, fNtotCurrentBuf=122634
Entry: 0, registering baskets branch pvx, fEntryNext=100, fNseek=14, fNtotCurrentBuf=129480
Entry: 0, registering baskets branch pvy, fEntryNext=100, fNseek=15, fNtotCurrentBuf=136292
Entry: 0, registering baskets branch pvz, fEntryNext=100, fNseek=16, fNtotCurrentBuf=143122
Entry: 0, registering baskets branch mass, fEntryNext=100, fNseek=17, fNtotCurrentBuf=159920
Entry: 0, registering baskets branch eventNumber, fEntryNext=100, fNseek=17, fNtotCurrentBuf=159920
Entry: 0, registering baskets branch runNumber, fEntryNext=100, fNseek=17, fNtotCurrentBuf=159920
Entry: 0, registering baskets branch lumiBlock, fEntryNext=100, fNseek=17, fNtotCurrentBuf=159920
Entry: 0, registering baskets branch decay, fEntryNext=100, fNseek=17, fNtotCurrentBuf=159920
Entry: 0, registering baskets branch PDGid, fEntryNext=100, fNseek=17, fNtotCurrentBuf=159920
Entry: 0, registering baskets branch mother, fEntryNext=100, fNseek=17, fNtotCurrentBuf=159920
Entry: 0, registering baskets branch fdaughter, fEntryNext=100, fNseek=17, fNtotCurrentBuf=159920
Entry: 0, registering baskets branch ldaughter, fEntryNext=100, fNseek=17, fNtotCurrentBuf=159920
Entry: 0, registering baskets branch status, fEntryNext=100, fNseek=17, fNtotCurrentBuf=159920
Entry: 0, registering baskets branch barcode, fEntryNext=100, fNseek=17, fNtotCurrentBuf=159920
Entry: 0, registering baskets branch pt, fEntryNext=100, fNseek=17, fNtotCurrentBuf=159920
Entry: 0, registering baskets branch theta, fEntryNext=100, fNseek=17, fNtotCurrentBuf=159920
Entry: 0, registering baskets branch phi, fEntryNext=100, fNseek=17, fNtotCurrentBuf=159920
Entry: 0, registering baskets branch pvx, fEntryNext=100, fNseek=17, fNtotCurrentBuf=159920
Entry: 0, registering baskets branch pvy, fEntryNext=100, fNseek=17, fNtotCurrentBuf=159920
Entry: 0, registering baskets branch pvz, fEntryNext=100, fNseek=17, fNtotCurrentBuf=159920
Entry: 0, registering baskets branch mass, fEntryNext=100, fNseek=17, fNtotCurrentBuf=159920
Entry: 0, un-registering branch: eventNumber
Entry: 0, un-registering branch: runNumber
Entry: 0, un-registering branch: lumiBlock
Entry: 0, un-registering branch: decay
Entry: 0, un-registering branch: PDGid
Entry: 0, un-registering branch: mother
Entry: 0, un-registering branch: fdaughter
Entry: 0, un-registering branch: ldaughter
Entry: 0, un-registering branch: status
Entry: 0, un-registering branch: barcode
Entry: 0, un-registering branch: pt
Entry: 0, un-registering branch: theta
Entry: 0, un-registering branch: phi
Entry: 0, un-registering branch: pvx
Entry: 0, un-registering branch: pvy
Entry: 0, un-registering branch: pvz
Entry: 0, un-registering branch: mass
Entry: 0, registering branch: eventNumber
Entry: 0, registering branch: runNumber
Entry: 0, registering branch: lumiBlock
Info in <TInterpreter::TCling::AutoParse>: Trying to autoparse for vector<string>
Info in <TInterpreter::TCling::AutoParse>: Starting autoparse for string
Info in <TInterpreter::TCling::AutoParse>: Starting autoparse for vector<string>
Info in <TInterpreter::TCling::AutoParse>: Starting autoparse for string
Creating StreamerInfo for class: vector<string>, version: 6
StreamerInfo for class: vector<string>, version=6, checksum=0x0
vector<string> This offset= 0 type=300 ,stl=1, ctype=61, <string> Used to call the proper TStreamerInfo case
i= 0, This type=300, offset= 0, len=1, method=0
Entry: 0, registering branch: decay
StreamerInfoAction, class:vector<string>, name=This, fType[0]=300, TStreamerSTL, bufpos=78, arr=0x564a8a5e86a0, offset=0 ()
Entry: 0, registering branch: PDGid
StreamerInfoAction, class:vector<vector<int> >, name=This, fType[0]=300, TStreamerSTL, bufpos=78, arr=0x7f9fc4fc2010, offset=0 ()
*** Break *** segmentation violation
===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0 0x00007f9fc3c8489a in __GI___waitpid (pid=11009, stat_loc=stat_loc
entry=0x7ffe8ad623a8, options=options
entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:29
#1 0x00007f9fc3bf39cb in do_system (line=<optimized out>) at ../sysdeps/posix/system.c:148
#2 0x00007f9fc48163e7 in TUnixSystem::Exec (shellcmd=<optimized out>, this=0x564a87e80740) at /home/ktoms/root-6.11.02/core/unix/src/TUnixSystem.cxx:2118
#3 TUnixSystem::StackTrace (this=0x564a87e80740) at /home/ktoms/root-6.11.02/core/unix/src/TUnixSystem.cxx:2412
#4 0x00007f9fc4818a9c in TUnixSystem::DispatchSignals (this=0x564a87e80740, sig=kSigSegmentationViolation) at /home/ktoms/root-6.11.02/core/unix/src/TUnixSystem.cxx:3643
#5 <signal handler called>
#6 0x00007f9fb9f30b58 in ROOT::Detail::TCollectionProxyInfo::Pushback<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > >::resize(void*, unsigned long) () from /home/ktoms/work/AutoDict_vector_vector_int____cxx.so
#7 0x00007f9fc25ff28f in TGenCollectionStreamer::ReadObjects (this=this
entry=0x564a8a307dd0, nElements=2, b=..., onFileClass=onFileClass
entry=0x0) at /home/ktoms/root-6.11.02/io/io/src/TGenCollectionStreamer.cxx:380
#8 0x00007f9fc25ff81f in TGenCollectionStreamer::ReadBufferGeneric (this=0x564a8a307dd0, b=..., obj=0x7f9fc4fc2010, onFileClass=0x0) at /home/ktoms/root-6.11.02/io/io/src/TGenCollectionStreamer.cxx:1367
#9 0x00007f9fc25a0641 in TClass::Streamer (onfile_class=0x564a8a467140, b=..., obj=0x7f9fc4fc2010, this=0x564a8a467140) at /home/ktoms/build/include/TClass.h:548
#10 TBufferFile::ReadFastArray (this=0x564a8b1bf780, start=<optimized out>, cl=0x564a8a467140, n=<optimized out>, streamer=<optimized out>, onFileClass=0x564a8a467140) at /home/ktoms/root-6.11.02/io/io/src/TBufferFile.cxx:1677
#11 0x00007f9fc269bfc4 in TStreamerInfoActions::ReadSTLObjectWiseFastArray (conf=0x564a8a469470, addr=<optimized out>, buf=...) at /home/ktoms/root-6.11.02/io/io/src/TStreamerInfoActions.cxx:921
#12 TStreamerInfoActions::ReadSTL<&TStreamerInfoActions::ReadSTLMemberWiseSameClass, &TStreamerInfoActions::ReadSTLObjectWiseFastArray> (buf=..., addr=0x7f9fc4fc2010, conf=0x564a8a469470) at /home/ktoms/root-6.11.02/io/io/src/TStreamerInfoActions.cxx:964
#13 0x00007f9fc259fe5b in TStreamerInfoActions::TConfiguredAction::operator() (this=<optimized out>, this=<optimized out>, object=0x7f9fc4fc2010, buffer=...) at /home/ktoms/build/include/TStreamerInfoActions.h:116
#14 TBufferFile::ApplySequence (this=0x564a8b1bf780, sequence=..., obj=0x7f9fc4fc2010) at /home/ktoms/root-6.11.02/io/io/src/TBufferFile.cxx:4007
#15 0x00007f9fb9a76791 in TBranchElement::ReadLeavesMember (this=0x564a8b294490, b=...) at /home/ktoms/root-6.11.02/tree/tree/src/TBranchElement.cxx:4049
#16 0x00007f9fb9a695cc in TBranch::GetEntry (this=this
entry=0x564a8b294490, entry=entry
entry=0, getall=getall
entry=0) at /home/ktoms/root-6.11.02/tree/tree/src/TBranch.cxx:1317
#17 0x00007f9fb9a81b89 in TBranchElement::GetEntry (this=0x564a8b294490, entry=0, getall=0) at /home/ktoms/root-6.11.02/tree/tree/src/TBranchElement.cxx:2332
#18 0x00007f9fb9ac4611 in TTree::<lambda()>::operator() (__closure=<synthetic pointer>) at /home/ktoms/root-6.11.02/tree/tree/src/TTree.cxx:5379
#19 TTree::GetEntry (this=0x564a8a3419e0, entry=<optimized out>, getall=<optimized out>) at /home/ktoms/root-6.11.02/tree/tree/src/TTree.cxx:5453
#20 0x00007f9fc4fc2302 in ?? ()
#21 0x00007ffe8ad670a0 in ?? ()
#22 0x00007f9fc4fc2010 in ?? ()
#23 0x0000564a89422dc0 in ?? ()
#24 0x00007f9fc3c3b3fe in __GI___libc_free (mem=<optimized out>) at malloc.c:3144
#25 0x00007f9fbf85f317 in cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) [clone .part.308] () from /home/ktoms/root6/lib/libCling.so
#26 0x00007f9fbf861b89 in cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) () from /home/ktoms/root6/lib/libCling.so
#27 0x00007f9fbf90d273 in cling::MetaSema::actOnxCommand(llvm::StringRef, llvm::StringRef, cling::Value*) () from /home/ktoms/root6/lib/libCling.so
#28 0x00007f9fbf919437 in cling::MetaParser::isXCommand(cling::MetaSema::ActionResult&, cling::Value*) () from /home/ktoms/root6/lib/libCling.so
#29 0x00007f9fbf91a516 in cling::MetaParser::isCommand(cling::MetaSema::ActionResult&, cling::Value*) () from /home/ktoms/root6/lib/libCling.so
#30 0x00007f9fbf906dcb in cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) () from /home/ktoms/root6/lib/libCling.so
#31 0x00007f9fbf7ce7de in HandleInterpreterException (metaProcessor=0x564a882d5280, input_line=<optimized out>, compRes=
0x7ffe8ad67614: cling::Interpreter::kSuccess, result=result
entry=0x7ffe8ad67620) at /home/ktoms/root-6.11.02/core/metacling/src/TCling.cxx:1969
#32 0x00007f9fbf7de3d2 in TCling::ProcessLine (this=0x564a87ed63b0, line=<optimized out>, error=0x7ffe8ad6875c) at /home/ktoms/root-6.11.02/core/metacling/src/TCling.cxx:2111
#33 0x00007f9fbf7d14ba in TCling::ProcessLineSynch (this=0x564a87ed63b0, line=0x564a886ba160 ".X /home/ktoms/work/./test.cxx", error=0x7ffe8ad6875c) at /home/ktoms/root-6.11.02/core/metacling/src/TCling.cxx:2964
#34 0x00007f9fc46f63ac in TApplication::ExecuteFile (file=<optimized out>, error=0x7ffe8ad6875c, keep=<optimized out>) at /home/ktoms/root-6.11.02/core/base/src/TApplication.cxx:1189
#35 0x00007f9fc46f815d in TApplication::ProcessLine (this=0x564a87ecbf90, line=<optimized out>, sync=<optimized out>, err=0x7ffe8ad6875c) at /home/ktoms/root-6.11.02/core/base/src/TApplication.cxx:1034
#36 0x00007f9fc4b895b2 in TRint::ProcessLineNr (this=this
entry=0x564a87ecbf90, filestem=filestem
entry=0x7f9fc4b9b29c "ROOT_cli_", line=line
entry=0x7ffe8ad68760 ".x test.cxx", error=error
entry=0x7ffe8ad6875c) at /home/ktoms/root-6.11.02/core/rint/src/TRint.cxx:756
#37 0x00007f9fc4b8ac88 in TRint::Run (this=0x564a87ecbf90, retrn=<optimized out>) at /home/ktoms/root-6.11.02/core/rint/src/TRint.cxx:416
#38 0x0000564a876a0dcc in main (argc=<optimized out>, argv=0x7ffe8ad6a8e8) at /home/ktoms/root-6.11.02/main/src/rmain.cxx:30
===========================================================
The lines below might hint at the cause of the crash.
===========================================================
#6 0x00007f9fb9f30b58 in ROOT::Detail::TCollectionProxyInfo::Pushback<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > >::resize(void*, unsigned long) () from /home/ktoms/work/AutoDict_vector_vector_int____cxx.so
#7 0x00007f9fc25ff28f in TGenCollectionStreamer::ReadObjects (this=this
entry=0x564a8a307dd0, nElements=2, b=..., onFileClass=onFileClass
entry=0x0) at /home/ktoms/root-6.11.02/io/io/src/TGenCollectionStreamer.cxx:380
#8 0x00007f9fc25ff81f in TGenCollectionStreamer::ReadBufferGeneric (this=0x564a8a307dd0, b=..., obj=0x7f9fc4fc2010, onFileClass=0x0) at /home/ktoms/root-6.11.02/io/io/src/TGenCollectionStreamer.cxx:1367
#9 0x00007f9fc25a0641 in TClass::Streamer (onfile_class=0x564a8a467140, b=..., obj=0x7f9fc4fc2010, this=0x564a8a467140) at /home/ktoms/build/include/TClass.h:548
#10 TBufferFile::ReadFastArray (this=0x564a8b1bf780, start=<optimized out>, cl=0x564a8a467140, n=<optimized out>, streamer=<optimized out>, onFileClass=0x564a8a467140) at /home/ktoms/root-6.11.02/io/io/src/TBufferFile.cxx:1677
#11 0x00007f9fc269bfc4 in TStreamerInfoActions::ReadSTLObjectWiseFastArray (conf=0x564a8a469470, addr=<optimized out>, buf=...) at /home/ktoms/root-6.11.02/io/io/src/TStreamerInfoActions.cxx:921
#12 TStreamerInfoActions::ReadSTL<&TStreamerInfoActions::ReadSTLMemberWiseSameClass, &TStreamerInfoActions::ReadSTLObjectWiseFastArray> (buf=..., addr=0x7f9fc4fc2010, conf=0x564a8a469470) at /home/ktoms/root-6.11.02/io/io/src/TStreamerInfoActions.cxx:964
#13 0x00007f9fc259fe5b in TStreamerInfoActions::TConfiguredAction::operator() (this=<optimized out>, this=<optimized out>, object=0x7f9fc4fc2010, buffer=...) at /home/ktoms/build/include/TStreamerInfoActions.h:116
#14 TBufferFile::ApplySequence (this=0x564a8b1bf780, sequence=..., obj=0x7f9fc4fc2010) at /home/ktoms/root-6.11.02/io/io/src/TBufferFile.cxx:4007
#15 0x00007f9fb9a76791 in TBranchElement::ReadLeavesMember (this=0x564a8b294490, b=...) at /home/ktoms/root-6.11.02/tree/tree/src/TBranchElement.cxx:4049
#16 0x00007f9fb9a695cc in TBranch::GetEntry (this=this
entry=0x564a8b294490, entry=entry
entry=0, getall=getall
entry=0) at /home/ktoms/root-6.11.02/tree/tree/src/TBranch.cxx:1317
#17 0x00007f9fb9a81b89 in TBranchElement::GetEntry (this=0x564a8b294490, entry=0, getall=0) at /home/ktoms/root-6.11.02/tree/tree/src/TBranchElement.cxx:2332
#18 0x00007f9fb9ac4611 in TTree::<lambda()>::operator() (__closure=<synthetic pointer>) at /home/ktoms/root-6.11.02/tree/tree/src/TTree.cxx:5379
#19 TTree::GetEntry (this=0x564a8a3419e0, entry=<optimized out>, getall=<optimized out>) at /home/ktoms/root-6.11.02/tree/tree/src/TTree.cxx:5453
#20 0x00007f9fc4fc2302 in ?? ()
#21 0x00007ffe8ad670a0 in ?? ()
#22 0x00007f9fc4fc2010 in ?? ()
#23 0x0000564a89422dc0 in ?? ()
#24 0x00007f9fc3c3b3fe in __GI___libc_free (mem=<optimized out>) at malloc.c:3144
#25 0x00007f9fbf85f317 in cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) [clone .part.308] () from /home/ktoms/root6/lib/libCling.so
#26 0x00007f9fbf861b89 in cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) () from /home/ktoms/root6/lib/libCling.so
#27 0x00007f9fbf90d273 in cling::MetaSema::actOnxCommand(llvm::StringRef, llvm::StringRef, cling::Value*) () from /home/ktoms/root6/lib/libCling.so
#28 0x00007f9fbf919437 in cling::MetaParser::isXCommand(cling::MetaSema::ActionResult&, cling::Value*) () from /home/ktoms/root6/lib/libCling.so
#29 0x00007f9fbf91a516 in cling::MetaParser::isCommand(cling::MetaSema::ActionResult&, cling::Value*) () from /home/ktoms/root6/lib/libCling.so
#30 0x00007f9fbf906dcb in cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) () from /home/ktoms/root6/lib/libCling.so
#31 0x00007f9fbf7ce7de in HandleInterpreterException (metaProcessor=0x564a882d5280, input_line=<optimized out>, compRes=
0x7ffe8ad67614: cling::Interpreter::kSuccess, result=result
entry=0x7ffe8ad67620) at /home/ktoms/root-6.11.02/core/metacling/src/TCling.cxx:1969
===========================================================
Root >
Thanks a lot for any advice,
Konstantin