Skip to content

Commit

Permalink
Avoid access gROOT after its teardown in destructors (Fix ROOT-8395)
Browse files Browse the repository at this point in the history
  • Loading branch information
pcanal committed Oct 13, 2016
1 parent f7c399e commit fe42bc0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion graf2d/graf/src/TCutG.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ TCutG::~TCutG()
{
delete fObjectX;
delete fObjectY;
gROOT->GetListOfSpecials()->Remove(this);
if ( gROOT && !gROOT->TestBit( TObject::kInvalidObject ) )
gROOT->GetListOfSpecials()->Remove(this);
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
3 changes: 2 additions & 1 deletion math/fumili/src/TFumili.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ void TFumili::BuildArrays(){

TFumili::~TFumili() {
DeleteArrays();
gROOT->GetListOfSpecials()->Remove(this);
if (gROOT && !gROOT->TestBit(TObject::kInvalidObject))
gROOT->GetListOfSpecials()->Remove(this);
if (gFumili == this) gFumili = 0;
}

Expand Down
3 changes: 2 additions & 1 deletion montecarlo/eg/src/TDatabasePDG.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ TDatabasePDG::~TDatabasePDG()
fListOfClasses->Delete();
delete fListOfClasses;
}
gROOT->GetListOfSpecials()->Remove(this);
if (gROOT && !gROOT->TestBit(TObject::kInvalidObject))
gROOT->GetListOfSpecials()->Remove(this);
auto fgInstance = GetInstancePtr();
*fgInstance = nullptr;
}
Expand Down
8 changes: 5 additions & 3 deletions tree/tree/src/TChain.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ TChain::TChain(const char* name, const char* title)

TChain::~TChain()
{
gROOT->GetListOfCleanups()->Remove(this);
bool rootAlive = gROOT && !gROOT->TestBit(TObject::kInvalidObject);

if (rootAlive) gROOT->GetListOfCleanups()->Remove(this);

SafeDelete(fProofChain);
fStatus->Delete();
Expand All @@ -196,10 +198,10 @@ TChain::~TChain()
delete[] fTreeOffset;
fTreeOffset = 0;

gROOT->GetListOfSpecials()->Remove(this);
if (rootAlive) gROOT->GetListOfSpecials()->Remove(this);

// Remove from the global list
gROOT->GetListOfDataSets()->Remove(this);
if (rootAlive) gROOT->GetListOfDataSets()->Remove(this);

// This is the same as fFile, don't delete it a second time.
fDirectory = 0;
Expand Down

0 comments on commit fe42bc0

Please sign in to comment.