[ROOT] Order of deletion in CINT

From: Thomas Bretz (tbretz@astro.uni-wuerzburg.de)
Date: Wed Aug 18 2004 - 17:11:25 MEST


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