RE: [ROOT] Order of deletion in CINT

From: Philippe Canal (pcanal@fnal.gov)
Date: Wed Aug 18 2004 - 21:07:55 MEST


Hi Thomas,

The list of file should be deleted after then end of main and hence
after the end of the macro.

I can not reproduce the problem.

I recommend that you run valgrind over root.exe in your case to
see what it reports.  Alternatively, you could try to put a break
point in the TFile destructor and see when that is called relative
to your crash.

Cheers,
Philippe.

-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Thomas Bretz
Sent: Wednesday, August 18, 2004 10:11 AM
To: roottalk@pcroot.cern.ch
Subject: [ROOT] Order of deletion in CINT


Hi,

I have a question. I have a class
class A : public TObject {
TFile *f;
A() { f=new TFile("myfile.root"); }
~A() { cout << f->GetName() << endl; delete f; }
};

and a macro
void macro() { A a; [some code] }

Let this macro run in some conditions (which I cannot name) the 
destructor of A crashed. After some debugging I found out, that the 
pointer points to an invalid location. The only idea I have is, that the 
TFile gets deleted via gROOT->GetListOfFiles() (because after 
constructor of TFile the kCanDeleteBit is set).

But what could be the reason, that the ListOfFiles() deletes all files?

Note that I start the macro with:
root -q macro.C

More strange if I change the timing of the code (just by adding 
additional output somewhere) the problem gets even worse or better. Is 
it possible that you have two concurrent threads when a root exits 
because the macro has finished? One which deletes A and one which 
already deleted the TFile (because it was faster)?

Best regards,
Thomas.



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:09 MET