Strange behaviour in cint

Hi folks,

This evening I have encounter a problem when using root and after trying to solve it
since a few hours i have decided to communicate it to the list.
I have tried with root version 3.05.07 and 3.10.02.

I use the following code ( to analyse a root file which contains a tree with an event class.

#include <stdlib.h>
#include <TStyle.h>
#include <TFile.h>
#include <TCanvas.h>
#include <TBox.h>
#include <TH1.h>
#include <TPad.h>
#include <TPaveLabel.h>
#include <TPostScript.h>
#include "TClonesArray.h"
#include "TObject.h"
#include "TMap.h"
#include "TRefArray.h"
#include "TRef.h"
#include "TTree.h"
#include "Riostream.h"
#include <vector>
//#include "libevent/Event.h"
TH1F *h;

void anaroot(){
  h = new TH1F("myfirst","MiniCal: Total Energy Dep. in Xtal",100, 0., 0.0042); 
  //if(!TClassTable::GetDict("myEvent")) {

  TFile* f = new TFile("run105_my.root");
  TTree* t = (TTree*) f->Get("T");
  myEvent* event = 0;
  EventHeader *header = 0;
  Int_t nentries = (Int_t) t->GetEntries(); 
  Int_t ncells = 0;
  cout << t << ", " << nentries << endl; 
  // event loop
  for (Int_t i=0; i < nentries; i++){
    ncells = event->GetNCells();
    cout << "i, ncells= " << i << ", " << ncells << endl; 
    TClonesArray* cellsArr  =  event->GetCells();
    AnaCaloCell* calocell = 0;
    Float_t toteneg = 0.;
    if (ncells > 0) {
      for (Int_t j=0; j < ncells; j++){
        calocell = (AnaCaloCell *) cellsArr->At(j);
        cout << calocell << ", " << j << endl; 
        Float_t eneg = calocell->GetEnergy();   
        cout << eneg << endl; 
        toteneg += eneg;
  //  delete f;

In the root file there are events in which the calocell under investigation was not
hit by a particle.

If I execute the code within cint (version 5.15.115)


it runs fine when executing it for the first time within an interactive root session.

If I, however, run it in the same root session for a second time without changing anything
it dies with the following error output

i, ncells= 46, 1
(nil), 0

*** Break *** segmentation violation
Generating stack trace…
0x417edbbe in G__cpp_dllrevEventDict at /afs/ from /data/poeschl/e166/CsI-g4/./
0x406b352b in G__exec_asm + 0x8eb from /products/ROOT/3.10_02/gcc-2.95.3/root/lib/
0x406a4df8 in G__exec_loop + 0x50c from /products/ROOT/3.10_02/gcc-2.95.3/root/lib/
0x406a537b in G__exec_for + 0x313 from /products/ROOT/3.10_02/gcc-2.95.3/root/lib/
0x406a804e in G__exec_statement + 0x29e2 from /products/ROOT/3.10_02/gcc-2.95.3/root/lib/
0x406761fc in G__interpret_func + 0x21c4 from /products/ROOT/3.10_02/gcc-2.95.3/root/lib/
0x4065a69e in G__getfunction + 0x20e6 from /products/ROOT/3.10_02/gcc-2.95.3/root/lib/
0x4064ea2a in G__getitem + 0x76a from /products/ROOT/3.10_02/gcc-2.95.3/root/lib/
0x4064d082 in G__getexpr + 0x90f2 from /products/ROOT/3.10_02/gcc-2.95.3/root/lib/
0x40643bdd in G__calc_internal + 0x3dd from /products/ROOT/3.10_02/gcc-2.95.3/root/lib/
0x406ae7ff in G__process_cmd + 0x2677 from /products/ROOT/3.10_02/gcc-2.95.3/root/lib/
0x401a3781 in ProcessLine__5TCintPCcPQ212TInterpreter10EErrorCode + 0xa1 from /products/ROOT/3.10_02/gcc-2.95.3/root/lib/
0x401a38a3 in ProcessLineSynch__5TCintPCcPQ212TInterpreter10EErrorCode + 0x4f from /products/ROOT/3.10_02/gcc-2.95.3/root/lib/
0x4012a9f4 in ProcessFile__12TApplicationPCcPi + 0x6fc from /products/ROOT/3.10_02/gcc-2.95.3/root/lib/
0x4012a18a in ProcessLine__12TApplicationPCcbPi + 0x56a from /products/ROOT/3.10_02/gcc-2.95.3/root/lib/

In the given event i=46 the variable ncells is 0 in the first run (as it should be)
but 1 in a subsequent run leading to the crash (in fact it is 1 in all events).

I have no idea what is happening here. I cannot imgine that my root file is corrupted
since as said before in the first go everything runs fine.

I can also (after including the Event.h file) compile the code and let it run as often as I want.

For convenience I have copied the root file under investigation to


and the files from which I create the shared library ( to


Any hint what’s going wrong would be great. As I said I see no indication that my
root file is corrupted.

Thanks in advance.



Hi Roman,

I cannot reproduce this problem. I always get the same result with
new calls. ncells is always 0 for i=46

I checked that teh results are OK with ROOT 3.05/07, 3.10/02
and 4.00/02