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

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


Aihong,

The line where your program crashes in TBuffer.cxx (line 2068) does not
exists in the official version of Root.
My guess is that you use the modified version of TBuffer::WriteObject
from Victor. If this is the case, see with him what is the problem.
I repeat that your program works correctly with the standard version of Root.

Rene Brun

Aihong Tang wrote:
> 
> Hi, Rene:
> 
> Yes I shoud delete graph1 and graph2, but that does not help.
> Following is what I got (on linux)  :
> 
> [rcas6008] /star/rcf/scratch/aihong/producePar/treetest > gdb `which
> root4star`
> GNU gdb 4.17
> Copyright 1998 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you
> are
> welcome to change it and/or distribute copies of it under certain
> conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for
> details.
> This GDB was configured as "i686-pc-linux-gnu"...
> (gdb) run
> Starting program:
> /afs/rhic/star/packages/DEV00/.i386_redhat61/bin/root4star
>   *******************************************
>   *                                         *
>   *        W E L C O M E  to  R O O T       *
>   *                                         *
>   *   Version   2.24/05      17 June 2000   *
>    *                                         *
>   *  You are welcome to visit our Web site  *
>   *          http://root.cern.ch            *
>   *                                         *
>   *******************************************
> 
> CINT/ROOT C/C++ Interpreter version 5.14.40, May 21 2000
> Type ? for help. Commands must be C++ statements.
> Enclose multiple statements between { }.
> 
> Welcome to the ROOT tutorials
> 
> Type ".x demos.C" to get a toolbar from which to execute the demos
> 
> Type ".x demoshelp.C" to see the help window
> 
>  *** Start at Date : 27-Jun-2000 Time : 8:56:9 ***
> QAInfo:You are using STAR_LEVEL : dev, ROOT_LEVEL : 2.24.05 and node :
> rcas6008.rcf.bnl.gov
> root4star [0] .x treetest.C
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x400814b1 in TBuffer::WriteObject (this=0x93ec880, obj=0x0, flag=0)
>     at .i386_redhat61/root/obj/base/src/TBuffer.cxx:2068
> 2068       Int_t   topTKey  = (topLevel &&
> strcmp("TKey",obj->ClassName())==0);
> (gdb)
> 
> I am completlely stuck, any help will be appreciated.
> 
> Thanks!
> 
> Aihong
> 
> On Tue, 27 Jun 2000, Rene Brun wrote:
> 
> > 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:29 MET