Skip to content

Commit

Permalink
Use a lock to protect access to collection from TROOT::GetListOfClean…
Browse files Browse the repository at this point in the history
…ups (resolve merge conflicts for 6.08)
  • Loading branch information
smuzaffar authored and pcanal committed May 16, 2017
1 parent 1deb07c commit 138c7ce
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 13 deletions.
2 changes: 2 additions & 0 deletions core/base/src/TObject.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class hierarchies (watch out for overlaps).
#include "TObjString.h"
#include "TRefTable.h"
#include "TProcessID.h"
#include "TVirtualMutex.h"

Long_t TObject::fgDtorOnly = 0;
Bool_t TObject::fgObjectStat = kTRUE;
Expand Down Expand Up @@ -148,6 +149,7 @@ TObject::~TObject()
if (root->MustClean()) {
if (root == this) return;
if (TestBit(kMustCleanup)) {
R__LOCKGUARD2(gROOTMutex);
root->GetListOfCleanups()->RecursiveRemove(this);
}
}
Expand Down
14 changes: 11 additions & 3 deletions core/base/src/TObjectSpy.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include "TObjectSpy.h"
#include "TROOT.h"

#include "TVirtualMutex.h"

/** \class TObjectRefSpy
\class TObjectSpy
Expand All @@ -35,7 +35,10 @@ ClassImp(TObjectRefSpy)
TObjectSpy::TObjectSpy(TObject *obj, Bool_t fixMustCleanupBit) :
TObject(), fObj(obj), fResetMustCleanupBit(kFALSE)
{
gROOT->GetListOfCleanups()->Add(this);
{
R__LOCKGUARD2(gROOTMutex);
gROOT->GetListOfCleanups()->Add(this);
}
if (fObj && !fObj->TestBit(kMustCleanup)) {
if (fixMustCleanupBit) {
fResetMustCleanupBit = kTRUE;
Expand All @@ -53,6 +56,7 @@ TObjectSpy::~TObjectSpy()
{
if (fObj && fResetMustCleanupBit)
fObj->SetBit(kMustCleanup, kFALSE);
R__LOCKGUARD2(gROOTMutex);
gROOT->GetListOfCleanups()->Remove(this);
}

Expand Down Expand Up @@ -98,7 +102,10 @@ void TObjectSpy::SetObject(TObject *obj, Bool_t fixMustCleanupBit)
TObjectRefSpy::TObjectRefSpy(TObject *&obj, Bool_t fixMustCleanupBit) :
fObj(obj), fResetMustCleanupBit(kFALSE)
{
gROOT->GetListOfCleanups()->Add(this);
{
R__LOCKGUARD2(gROOTMutex);
gROOT->GetListOfCleanups()->Add(this);
}
if (fObj && !fObj->TestBit(kMustCleanup)) {
if (fixMustCleanupBit) {
fResetMustCleanupBit = kTRUE;
Expand All @@ -116,6 +123,7 @@ TObjectRefSpy::~TObjectRefSpy()
{
if (fObj && fResetMustCleanupBit)
fObj->SetBit(kMustCleanup, kFALSE);
R__LOCKGUARD2(gROOTMutex);
gROOT->GetListOfCleanups()->Remove(this);
}

Expand Down
13 changes: 10 additions & 3 deletions hist/hist/src/THStack.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "TBrowser.h"
#include "TMath.h"
#include "TObjString.h"
#include "TVirtualMutex.h"

ClassImp(THStack)

Expand Down Expand Up @@ -129,6 +130,7 @@ THStack::THStack(const char *name, const char *title)
fHistogram = 0;
fMaximum = -1111;
fMinimum = -1111;
R__LOCKGUARD2(gROOTMutex);
gROOT->GetListOfCleanups()->Add(this);
}

Expand Down Expand Up @@ -172,8 +174,10 @@ THStack::THStack(TH1* hist, Option_t *axis /*="x"*/,
fHistogram = 0;
fMaximum = -1111;
fMinimum = -1111;
gROOT->GetListOfCleanups()->Add(this);

{
R__LOCKGUARD2(gROOTMutex);
gROOT->GetListOfCleanups()->Add(this);
}
if (!axis) {
Warning("THStack", "Need an axis.");
return;
Expand Down Expand Up @@ -316,7 +320,10 @@ THStack::THStack(TH1* hist, Option_t *axis /*="x"*/,
THStack::~THStack()
{

gROOT->GetListOfCleanups()->Remove(this);
{
R__LOCKGUARD2(gROOTMutex);
gROOT->GetListOfCleanups()->Remove(this);
}
if (!fHists) return;
fHists->Clear("nodelete");
delete fHists;
Expand Down
7 changes: 6 additions & 1 deletion io/io/src/TFileMerger.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ to be merged, like the standalone hadd program.
#include "TClassRef.h"
#include "TROOT.h"
#include "TMemFile.h"
#include "TVirtualMutex.h"

#ifdef WIN32
// For _getmaxstdio
Expand Down Expand Up @@ -99,6 +100,7 @@ TFileMerger::TFileMerger(Bool_t isLocal, Bool_t histoOneGo)
fExcessFiles = new TList;
fExcessFiles->SetOwner(kTRUE);

R__LOCKGUARD2(gROOTMutex);
gROOT->GetListOfCleanups()->Add(this);
}

Expand All @@ -107,7 +109,10 @@ TFileMerger::TFileMerger(Bool_t isLocal, Bool_t histoOneGo)

TFileMerger::~TFileMerger()
{
gROOT->GetListOfCleanups()->Remove(this);
{
R__LOCKGUARD2(gROOTMutex);
gROOT->GetListOfCleanups()->Remove(this);
}
SafeDelete(fFileList);
SafeDelete(fMergeList);
SafeDelete(fOutputFile);
Expand Down
2 changes: 2 additions & 0 deletions net/http/src/TRootSniffer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "TImage.h"
#include "RZip.h"
#include "RVersion.h"
#include "TVirtualMutex.h"
#include "TRootSnifferStore.h"
#include "THttpCallArg.h"

Expand Down Expand Up @@ -1949,6 +1950,7 @@ TObject *TRootSniffer::GetItem(const char *fullname, TFolder *&parent, Bool_t fo
httpfold = topf->AddFolder("http", "ROOT http server");
httpfold->SetBit(kCanDelete);
// register top folder in list of cleanups
R__LOCKGUARD2(gROOTMutex);
gROOT->GetListOfCleanups()->Add(httpfold);
}

Expand Down
18 changes: 15 additions & 3 deletions tree/tree/src/TChain.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ the trees in the chain.
#include "TEntryListFromFile.h"
#include "TFileStager.h"
#include "TFilePrefetch.h"
#include "TVirtualMutex.h"

ClassImp(TChain)

Expand Down Expand Up @@ -89,6 +90,7 @@ TChain::TChain()
gROOT->GetListOfDataSets()->Add(this);

// Make sure we are informed if the TFile is deleted.
R__LOCKGUARD2(gROOTMutex);
gROOT->GetListOfCleanups()->Add(this);
}

Expand Down Expand Up @@ -165,6 +167,7 @@ TChain::TChain(const char* name, const char* title)
gROOT->GetListOfDataSets()->Add(this);

// Make sure we are informed if the TFile is deleted.
R__LOCKGUARD2(gROOTMutex);
gROOT->GetListOfCleanups()->Add(this);
}

Expand All @@ -175,7 +178,10 @@ TChain::~TChain()
{
bool rootAlive = gROOT && !gROOT->TestBit(TObject::kInvalidObject);

if (rootAlive) gROOT->GetListOfCleanups()->Remove(this);
if (rootAlive) {
R__LOCKGUARD2(gROOTMutex);
gROOT->GetListOfCleanups()->Remove(this);
}

SafeDelete(fProofChain);
fStatus->Delete();
Expand Down Expand Up @@ -2810,7 +2816,10 @@ void TChain::Streamer(TBuffer& b)
{
if (b.IsReading()) {
// Remove using the 'old' name.
gROOT->GetListOfCleanups()->Remove(this);
{
R__LOCKGUARD2(gROOTMutex);
gROOT->GetListOfCleanups()->Remove(this);
}

UInt_t R__s, R__c;
Version_t R__v = b.ReadVersion(&R__s, &R__c);
Expand All @@ -2831,7 +2840,10 @@ void TChain::Streamer(TBuffer& b)
//====end of old versions
}
// Re-add using the new name.
gROOT->GetListOfCleanups()->Add(this);
{
R__LOCKGUARD2(gROOTMutex);
gROOT->GetListOfCleanups()->Add(this);
}

} else {
b.WriteClassBuffer(TChain::Class(),this);
Expand Down
11 changes: 9 additions & 2 deletions tree/tree/src/TTree.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ End_Macro
#include "TSchemaRuleSet.h"
#include "TFileMergeInfo.h"
#include "ROOT/StringConv.hxx"
#include "TVirtualMutex.h"

#include "TBranchIMTHelper.h"

Expand Down Expand Up @@ -880,7 +881,10 @@ TTree::~TTree()
}
if (fClones) {
// Clone trees should no longer be removed from fClones when they are deleted.
gROOT->GetListOfCleanups()->Remove(fClones);
{
R__LOCKGUARD2(gROOTMutex);
gROOT->GetListOfCleanups()->Remove(fClones);
}
// Note: fClones does not own its content.
delete fClones;
fClones = 0;
Expand Down Expand Up @@ -1104,7 +1108,10 @@ void TTree::AddClone(TTree* clone)
fClones->SetOwner(false);
// So that the clones are automatically removed from the list when
// they are deleted.
gROOT->GetListOfCleanups()->Add(fClones);
{
R__LOCKGUARD2(gROOTMutex);
gROOT->GetListOfCleanups()->Add(fClones);
}
}
if (!fClones->FindObject(clone)) {
fClones->Add(clone);
Expand Down
7 changes: 6 additions & 1 deletion tree/treeplayer/src/TTreePlayer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ extra libraries (Histogram, display, etc).
#include "TVirtualMonitoring.h"
#include "TTreeCache.h"
#include "TStyle.h"
#include "TVirtualMutex.h"

#include "HFitInterface.h"
#include "Foption.h"
Expand Down Expand Up @@ -112,7 +113,10 @@ TTreePlayer::TTreePlayer()
fInput->Add(new TNamed("varexp",""));
fInput->Add(new TNamed("selection",""));
fSelector->SetInputList(fInput);
gROOT->GetListOfCleanups()->Add(this);
{
R__LOCKGUARD2(gROOTMutex);
gROOT->GetListOfCleanups()->Add(this);
}
TClass::GetClass("TRef")->AdoptReferenceProxy(new TRefProxy());
TClass::GetClass("TRefArray")->AdoptReferenceProxy(new TRefArrayProxy());
}
Expand All @@ -127,6 +131,7 @@ TTreePlayer::~TTreePlayer()
DeleteSelectorFromFile();
fInput->Delete();
delete fInput;
R__LOCKGUARD2(gROOTMutex);
gROOT->GetListOfCleanups()->Remove(this);
}

Expand Down

0 comments on commit 138c7ce

Please sign in to comment.