From 84c704bba911a41d5fc9a201f45d59070e33cd29 Mon Sep 17 00:00:00 2001 From: Philippe Canal Date: Tue, 15 Aug 2023 19:39:58 -0500 Subject: [PATCH] Delete the object held by gROOT after we reset the globals. For example this allows unique_ptr to be deleted first and thus inform TROOT if need be. Fix #13462 --- core/base/src/TROOT.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/base/src/TROOT.cxx b/core/base/src/TROOT.cxx index ba74633d01dd7..9f5c95ea8e841 100644 --- a/core/base/src/TROOT.cxx +++ b/core/base/src/TROOT.cxx @@ -1129,11 +1129,12 @@ namespace { void TROOT::CloseFiles() { + // Close files without deleting the objects (ResetGlobals will be called next) if (fFiles && fFiles->First()) { R__ListSlowClose(static_cast(fFiles)); } // and Close TROOT itself. - Close("slow"); + Close("nodelete"); // Now sockets. if (fSockets && fSockets->First()) { if (nullptr==fCleanups->FindObject(fSockets) ) { @@ -1212,14 +1213,17 @@ void TROOT::EndOfProcessCleanups() CloseFiles(); if (gInterpreter) { + // This might delete some of the object 'held' by the TFiles (hence + // `CloseFiles` must not delete them) gInterpreter->ResetGlobals(); } - // Now delete the objects 'held' by the TFiles so that it + // Now delete the objects still 'held' by the TFiles so that it // is done before the tear down of the libraries. if (fClosedObjects && fClosedObjects->First()) { R__ListSlowDeleteContent(static_cast(fClosedObjects)); } + fList->Delete("slow"); // Now a set of simpler things to delete. See the same ordering in // TROOT::~TROOT