Segmentation Fault upon termination of program with ROOT 5.22/00b

From: Venkatesh Kaushik <venkat_at_hepmail.uta.edu>
Date: Mon, 1 Jun 2009 21:57:29 +0200


Hi,

I am using ATLAS software with ROOT v 5.22/00b /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/bin/root

I am not sure how to give a "simple" example of how to reproduce the crash I am getting without going into details about the program I am using, but I will certainly try. I should also mention that this crash did not occur
in earlier release (5.18/00f)

  1. I am using a program (written in python) that creates a "transient tree" from an input data file. This memory resident tree is then accessed by my program.

Here's the python interface that calls this program and "creates" the transient
tree: (see attached ARATree.py)

I have a program in c++ which accesses the transient tree, does some analysis (the skeleton was written using TTree->MakeClass() using
this transient tree as input). The program runs fine. Upon termination of my program
I get a segmentation fault. The main program is given here (run.cxx)

I give also the stack trace ( stack_trace.txt if its of any help) for this: I have to mention that the
snippets I have provided are not sufficient (by themselves) to reproduce the crash.
Apologies. Any help is appreciated. I am willing to provide more information (other
package dependencies etc.)

# import libraries

import user
import ROOT
import PyCintex
import os
import sys
import AthenaROOTAccess.transientTree

# create a list of input files (local analysis)
def ReadFile(fileslist, nEvents) :

    namelist = []
    os.path.isfile(fileslist)
    FILE = open(fileslist,"r")
    for line in FILE :

        if type(line) == type("") :
            namelist.append(line.rstrip('\n'))
    FILE.close()
    print "--> reading " + str(len(namelist)) + " file(s) from " + os.path.dirname(namelist[0]) + "/"     shortlist = namelist
    if nEvents != -1 :
      print "--> determining number of files to open for " + str(nEvents) + " event(s)"
      shortlist = shortList(namelist, nEvents)
    for i in shortlist :
      print "--> " + os.path.basename(i)
    return shortlist

# select files based on no. of events

def shortList(namelist, nEvents) :

    ntotal = 0
    ncount = 0
    for i in namelist :

      f = ROOT.TFile.Open (i)
      tree = f.Get ('CollectionTree')
      nentries = tree.GetEntries()
      ntotal += nentries
      ncount += 1
      if ntotal >= nEvents :
        break
    if ncount <= len(namelist) :
      namelist[ncount:len(namelist)] = []
    print "--> found " + str(ntotal) + " event(s) in " + str(len(namelist)) + " file(s)"     return namelist

# create a transient tree

def ARAtree(filelist, brNames = {}) :
  PyCintex.gbl.gEnv.SetValue("Root.ErrorIgnoreLevel", "Info")   chain = ROOT.AthenaROOTAccess.TChainROOTAccess('CollectionTree')   from glob import glob
  if type(filelist) is not list:
    filelist = glob(filelist)
  for i in filelist:
    chain.Add(i)
  tt = AthenaROOTAccess.transientTree.makeTree(chain, branchNames = brNames)   tt.chain = chain
  ROOT.SetOwnership(tt, True)
  return tt

#include <sstream>
#include <vector>
#include <cstdlib>

// local includes
#include "ARATopAnalysis/ARATree.h"
#include "ARATopAnalysis/TopAnalysis.h"

// ROOT includes
#include "TStopwatch.h"
#include "TPython.h"
#include "TTree.h"

// namespaces
using namespace std;

// helper function: event loop
void loop(int nEvents){

  // define a top analysis object (one of the analysis objects)   TopAnalysis *m_topAnalyser = new TopAnalysis("myTopAnalysis");   

  // make a list of analysis objects
  std::vector<myAnalysis*> myAnalysers;
  myAnalysers.push_back(m_topAnalyser);

  // hook the transient tree to analysis   ARATree tree("myARATree");
  TStopwatch timer;
  timer.Start();
  // enter event loop with the list of analysers / number of events   int nEventsAnalysed = tree.Loop(nEvents,myAnalysers);   timer.Stop();

  // finish analysis (save histograms etc.)   m_topAnalyser->EndAnalysis();         

  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();

  // print execution time

  std::cout << "Analysed events: " << nEventsAnalysed << std::endl;
  std::cout << "RealTime: " << rtime << " seconds. \t CpuTime: " << ctime << " seconds" << std::endl;
  std::cout << "Execution time: " << nEventsAnalysed/rtime << " events / RealTime second. \t";
  std::cout << nEventsAnalysed/ctime << " events / CpuTime second." << std::endl;

  // delete all analysers
  for(unsigned int i=0;i<myAnalysers.size();++i) delete myAnalysers[i];

  // done
}

// helper function: make ARA transient tree TTree *MakeTree(string inputfilename) {

  static bool passOne = true;
  // import python modules to read list of input files   // and create transient tree
  if(passOne) {
    TPython::Exec( "from ARATopAnalysis.ARATree import ARAtree" );     TPython::Exec( "from ARATopAnalysis.ARATree import ReadFile" );     passOne = false;
  }   

  // create a transient tree by invoking python module   std::ostringstream command;
  command << "ARAtree(ReadFile('" << inputfilename << "'))";   TTree* transTree = NULL;
  transTree = reinterpret_cast< TTree* >( ( void* ) TPython::Eval( command.str().c_str() ) );

  // exit if transient tree cannot be created   if( ! transTree ) {
    std::cout << "Couldn't create transient tree from persistent tree" << std::endl;     exit(1);
  }   

  // return transient tree to caller
  return transTree;

  // done
}

// main helper function: prepare transient tree and invoke event loop void analyzeSample(int nEvents, string sampleName, string program){

  // run in batch mode by default
  gROOT->SetBatch(kTRUE);      

  TStopwatch timer;
  timer.Start();
  // make transient tree
  TTree *trTree = MakeTree(sampleName);
  timer.Stop();
  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();

  // read number of entries in transient tree   int nEventS = nEvents;
  if(trTree) {
    Long64_t nentries = trTree->GetEntriesFast();     if(nEvents>nentries || nEvents == -1) nEventS = nentries;   }

  // invoke event loop
  loop(nEventS);
}

// main

int main(int argc, char ** argv){

  // set default number of events to process   // and the input file (in pwd)
  int nEvents = 1000;
  string sampleName = "filelist_top.txt";

  if(argc == 1) {
    printf("--> Usage: %s <nEvents> <sampleName>\n",argv[0]);     exit(1);
  }
  // get number of events to process and file list   // from command line
  if(argc>0) nEvents = atoi( argv[1]);
  if(argc>1) sampleName = argv[2];

  // name of this program
  string program = argv[0];

  // invoke main analysis
  analyzeSample(nEvents,sampleName,program);

  // return success
  return 0;   

}

--> runProg.exe : switching to batch mode ...  INFO runProg.exe : Initializing ARA transient tree. Could take a while, please wait...


--> reading 1 file(s) from /raid01/venkat/dataset/check/
--> determining number of files to open for 1 event(s)
--> found 250 event(s) in 1 file(s)
--> AOD.026357._00511.pool.root.1

Warning: Branch HLT_egamma renamed to HLT_egamma_1 to avoid duplicate name   Types: egammaContainer egDetailContainer AthenaHitsVector DEBUG initialized.
 INFO    runProg.exe             : ARA Initialization: RealTime: 33.3378 s 	 CpuTime: 30.7 s
 INFO    runProg.exe             : Looping over events
 ...
 ...
 INFO    myTopAnalysis           : Event #: 0		20 kB
 INFO    runProg.exe             : RealTime: 0.746056 seconds. 	 CpuTime: 0.76 seconds
 INFO    runProg.exe             : Execution time: 1.34038 events / RealTime second. 	1.31579 events / CpuTime second.

0x005fd7a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1 0x0390e0f3 in __waitpid_nocancel () from /lib/tls/libc.so.6
#2 0x038b77b9 in do_system () from /lib/tls/libc.so.6
#3 0x02e9f387 in TUnixSystem::Exec ()

   from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libCore.so
#4 0x02ea501f in TUnixSystem::StackTrace ()

   from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libCore.so
#5 0x02ea1a1a in TUnixSystem::DispatchSignals ()

   from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libCore.so
#6 0x02ea1aa8 in SigHandler () from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libCore.so
#7 0x02ea0d25 in sighandler () from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libCore.so
#8 <signal handler called>
#9 0x05bb5004 in ?? ()
#10 0x04064bd7 in Cint::G__ExceptionWrapper ()

   from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libCint.so
#11 0x0417c421 in G__callfunc0 () from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libCint.so
#12 0x0417c4cb in G__calldtor () from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libCint.so
#13 0x04097a5f in Cint::G__ClassInfo::Delete ()

   from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libCint.so
#14 0x02e944f6 in TCint::ClassInfo_Delete ()

   from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libCore.so
#15 0x02e648f4 in TClass::Destructor ()

   from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libCore.so
#16 0x06754d6d in TBranchElement::ReleaseObject ()

   from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libTree.so
#17 0x06755a18 in TBranchElement::ResetAddress ()

   from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libTree.so
#18 0x0495c50d in TConvertingBranchElement::ResetAddress ()

   from /afs/cern.ch/atlas/software/builds/AtlasCore/15.2.0/InstallArea/i686-slc4-gcc34-opt/lib/libRootConversions.so
#19 0x0495c76d in TConvertingBranchElement::~TConvertingBranchElement$delete ()

   from /afs/cern.ch/atlas/software/builds/AtlasCore/15.2.0/InstallArea/i686-slc4-gcc34-opt/lib/libRootConversions.so
#20 0x02e4c3b0 in TCollection::GarbageCollect ()

   from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libCore.so
#21 0x02e53c0b in TObjArray::Delete ()

   from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libCore.so
#22 0x0679458a in TTree::~TTree$delete ()

   from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libTree.so
#23 0x02e4c3b0 in TCollection::GarbageCollect ()

   from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libCore.so
#24 0x02e507a5 in TList::Delete () from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libCore.so
#25 0x02e4e41c in THashList::Delete ()

   from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libCore.so
#26 0x061b3d37 in TDirectoryFile::Close ()

   from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libRIO.so
#27 0x061c22d9 in TFile::Close () from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libRIO.so
#28 0x061c270c in TFile::~TFile$delete ()

   from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libRIO.so
#29 0x02e4c3b0 in TCollection::GarbageCollect ()

   from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libCore.so

#30 0x02e507b5 in TList::Delete () from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libCore.so
#31 0x02e04f3a in TROOT::~TROOT () from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libCore.so
#32 0x02e0525b in __tcf_0 () from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libCore.so
#33 0x038ad868 in __cxa_finalize () from /lib/tls/libc.so.6
#34 0x02dc1cfa in __do_global_dtors_aux ()

   from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libCore.so
#35 0x03143676 in _fini () from /afs/cern.ch/atlas/offline/external/LCGCMT/LCGCMT_56a/InstallArea/i686-slc4-gcc34-opt/lib/libCore.so
#36 0x00609e77 in _dl_fini () from /lib/ld-linux.so.2
#37 0x038ad5a7 in exit () from /lib/tls/libc.so.6
#38 0x03897dfd in __libc_start_main () from /lib/tls/libc.so.6
#39 0x08073651 in _start ()
Received on Mon Jun 01 2009 - 21:57:44 CEST

This archive was generated by hypermail 2.2.0 : Tue Jun 02 2009 - 11:50:02 CEST