Skip to content

Commit

Permalink
fix: Properly clean up TList in FairGeoSet
Browse files Browse the repository at this point in the history
FairGeoSet has non-owning references inside a TList to
FairGeoNodes.  When the dtor of FairGeoSet is called, those
FairGeoNodes might already have been destroyed.

Calling `Clear` with `"nodelete"` will just remove all the
references without touching them.
  • Loading branch information
ChristianTackeGSI committed Apr 22, 2024
1 parent 2668ed5 commit 9f31cd6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 1 addition & 3 deletions fairroot/geobase/FairGeoInterface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ FairGeoInterface::~FairGeoInterface()
masterNodes = 0;
}
if (sets) {
/// \bug Leaks "FairGeoSet"s and related resources, prevents memory issues (pr>
/// See: https://github.com/FairRootGroup/FairRoot/issues/1514
// sets->Delete();
sets->Delete();
delete sets;
sets = 0;
}
Expand Down
8 changes: 7 additions & 1 deletion fairroot/geobase/FairGeoSet.cxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
Expand Down Expand Up @@ -55,6 +55,12 @@ FairGeoSet::FairGeoSet()
FairGeoSet::~FairGeoSet()
{
// Destructor
if (volumes && !volumes->IsOwner()) {
// destructing a TList that doesn't own its contents
// still touches the objects inside, even if they're
// already destroeyed
volumes->Clear("nodelete");
}
delete volumes;
volumes = 0;
delete modules;
Expand Down

0 comments on commit 9f31cd6

Please sign in to comment.