Re: [ROOT] Bug or Feature: deleting TTrees in opened File

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Dec 20 2000 - 13:24:00 MET


Hi Birger,
What you do is perfectly legal and should not generate a crash.
I need a more detailed example to understand what can be the problem.
Could you provide a simple script with a small data file(s0 ?

Rene Brun

Birger Koblitz wrote:
> 
> Hi,
> 
> I had some truble finding a stupid bug I made. The code looked somewhat
> like this:
>         TFile *tf=new TFile("test.root");
>         t=(TTree *) tf->Get("ntuple");
>         [ use Tree ]
>         delete t;    <<<<<<<<<<<<<<
> 
> and then far away in a different Library:
>         TFile *tf =
>             (TFile*)gROOT->GetListOfFiles()->FindObject("test.root");
>         if(!tf) TFile *tf=new TFile("test.root");
>         t=(TTree *) tf->Get("ntuple");
>         [use t] .... crash
> So I asked myself: why should this dammn line crash? After some debugging
> I found the above error. But is it really an error? Why should calling a
> destructor on an ntuple out of a read-only file matter at all. Why does
> closing and reopening the file after deleting t not help? What is there
> lingering around in the system?
> I think this is a again a case of: This should be fixed in root if root is
> supposed to be foolproof.
> 
> Cheers,
>   Birger
> 
> /------------------------------------------------------------\
> | Birger Koblitz                    koblitz@mail.desy.de     |
> | Max-Planck-Institut fuer Physik                            |
> | (Werner Heisenberg-Institut)                               |
> | DESY-FH1K                         Tel. (40) 8998-3971      |
> | Notkestr. 85                                               |
> | D-22603  HAMBURG                                           |
> \------------------------------------------------------------/



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