Re: [ROOT] why TTree::Fill() crash?

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Jun 27 2000 - 08:53:00 MEST


Aihong,
I cannot reproduce your problem.

Note that there is something strange in your loop.
You should either delete graph1 and graph2 in the loop or move
the constructors outside the loop.

Rene Brun

Aihong Tang wrote:
> 
> Hi,
> 
> To simulate a crash recently found in my code, I wrote a simple code
> treetest.C.
> 
> The following code runs ok in root 2.23.12 but crashes in root 2.24.05,
> could anybody tell me the reason and how to fix it ?
> 
> I saw it on linux machine.
> 
> Thanks!
> 
> Aihong
> 
> void treetest(){
>     Int_t              bufSize=32000;
>     Int_t              splitLevel=0;
> 
>     TFile* file      = new TFile("File.root", "RECREATE");
>     TTree* tree      = new TTree("Tree", "A Foo Tree");
>     TObjArray* theArray= 0;
> 
>   TBranch* br=tree->Branch("tree","TObjArray", &theArray,
> bufSize,splitLevel);
> 
>    for (Int_t j=0; j < 10; j++){
> 
>     theArray=new TObjArray();
> 
>     TGraph* graph1 = new TGraph();
>     TH1F* graph2 = new TH1F("foo","foo",0,10,10);
> 
>       for (Int_t i = 0; i < 10; i++) {
>       graph1->SetPoint(i, i, i+1);
>       graph2->Fill(i);
>     }
> 
>      theArray->AddLast(graph1);
>      theArray->AddLast(graph2);
> 
>        tree->Fill(); // <========crash here
>    }
> 
>     //  tree->Print();
>     tree->Write();
>     file->Close();
> 
> 
>   }



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:28 MET