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

From: David Chamont (David.Chamont@poly.in2p3.fr)
Date: Fri Feb 08 2002 - 13:20:05 MET


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