Skip to content

Commit d060cd5

Browse files
committed
DPL Analysis: remove dead remote files from gROOT's list of files
TFile::Close() skips this for a TNetXNGFile after a fatal xrootd error, otherwise leaving a dangling pointer that crashes the reader later
1 parent 5b3c766 commit d060cd5

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎Framework/Core/src/RootArrowFilesystem.cxx‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include <TFile.h>
2020
#include <TBufferFile.h>
2121
#include <TDirectoryFile.h>
22+
#include <TROOT.h>
23+
#include <TVirtualMutex.h>
2224
#include <arrow/type.h>
2325
#include <arrow/type_fwd.h>
2426
#include <arrow/dataset/file_base.h>
@@ -47,6 +49,12 @@ TFileFileSystem::~TFileFileSystem()
4749
{
4850
if (mOwnsFile) {
4951
mFile->Close();
52+
{
53+
// TFile::Close() returns early when !IsOpen() (e.g. TNetXNGFile after a fatal xrootd error) and ~TFile doesn't
54+
// clean up either, so the file stays in gROOT's list of files. Remove it so the list doesn't keep a dangling pointer.
55+
R__LOCKGUARD(gROOTMutex);
56+
gROOT->GetListOfFiles()->Remove(mFile);
57+
}
5058
delete mFile;
5159
}
5260
}

0 commit comments

Comments
 (0)