Re: [ROOT] Problem with a Branch whose "buffer variable" is a pointer

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Feb 08 2002 - 23:14:13 MET


Hi David,

With all my apologies for the wrong information in my previous mail ::)
The object created by TTree::Branch in case the dictionary
for the class has not yet been built and the pointer is null
in input was correctly deleted, but the pointer was not set to 0.
I have added a fix for this case in the current CVS.
Thanks for the trivial example.

Rene Brun

On Fri, 8 Feb 2002, David Chamont wrote:

> Rene Brun wrote:
> 
> > Hi David,
> >
> > In order to organize the branches, ROOT has to build a detailed dictionary
> > for all the classes involved (top level classes, but also all referenced
> > classes). To build the dictionary, one has to build an instance of a class
> > and invoke the class ShowMembers function.
> > If the pointer specified to TTree::Branch is not null, ROOT will use
> > the corresponding object to build the dictionary, otherwise it will call
> > the class default constructor and will return the created object
> > at the pointer address. You can use this object if you like or delete it.
> 
> If I delete the object constructed by TTree::Branch, I obtain
> a segmentation violation. I use root 3.02/07 .  A very simplified script
> which violates segmentation is :
> 
>      #include "TFile.h"
>      #include "TTree.h"
>      #include "TLine.h"
> 
>      void demo()
>       {
>        TFile file("dummy.root","recreate") ;
>        TTree tree("dummy","dummy") ;
>        TLine * line = 0 ;
>        tree.Branch("lines","TLine",&line) ;
>        delete line ;
>       }
> 
> I use a TLine just for the demonstration, but I have also tried
> other classes which crash also. Perhaps I am doing an
> obvious error in the script above ?
> 
> I am also interested to know if there is a way to
> get back the hand when the root interpreter has
> encountered a "segmentation violation" and
> displayed the usual " busy flag cleared  "
> (control C has no effect).
> 
> Thanks.
> 
> David C.
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:41 MET