Skip to content

gGeoManager should not delete volumes in the FairRunAna destructor. #1600

@YanzhaoW

Description

@YanzhaoW

Describe the bug
Segmentation fault when FairRunAna object is deleted.

Stack info:

#7  0x00007f7fc00d081c in TObjArray::Delete (this=0x32fe2720) at /tmp/download/FairSoft-jan24p2/build/Source/root/core/cont/src/TObjArray.cxx:376
#8  0x00007f7fc1a989d1 in FairRunAna::~FairRunAna (this=0x2ffd8720, __in_chrg=<optimized out>) at /u/yanwang/software/src/FairRoot/fairroot/base/steer/FairRunAna.cxx:99
#9  0x00007f7fc1a98a39 in FairRunAna::~FairRunAna (this=0x2ffd8720, __in_chrg=<optimized out>) at /u/yanwang/software/src/FairRoot/fairroot/base/steer/FairRunAna.cxx:108
#10 0x00007f7fc5f72387 in std::default_delete<FairRun>::operator() (this=<optimized out>, __ptr=<optimized out>) at /usr/include/c++/14/bits/unique_ptr.h:87
#11 std::unique_ptr<FairRun, std::default_delete<FairRun> >::~unique_ptr (this=0x2ffd82e8, __in_chrg=<optimized out>) at /usr/include/c++/14/bits/unique_ptr.h:398
#12 R3B::Neuland::Application::~Application (this=0x2ffd8290, __in_chrg=<optimized out>) at /u/yanwang/software/R3BRoot/neuland/application/R3BNeulandApp.cxx:62
#13 0x00007f7fc5f403a5 in R3B::Neuland::AnalysisApplication::~AnalysisApplication (this=0x2ffd8290, __in_chrg=<optimized out>) at /usr/include/c++/14/bits/new_allocator.h:104
#14 R3B::Neuland::AnalysisApplication::~AnalysisApplication (this=0x2ffd8290, __in_chrg=<optimized out>) at /u/yanwang/software/R3BRoot/neuland/application/R3BNeulandAnalysisApp.h:25
#15 0x000000000040f65f in main (argc=<optimized out>, argv=<optimized out>) at /u/yanwang/software/R3BRoot/neuland/executables/neuland_cli.cxx:63

Further information:

As ROOT clearly states that users of gGeoManager should not control the deletion of its geometry object:

TGeoManager is the owner of all geometry objects defined in a session, therefore users must not try to control their deletion. It contains lists of media, materials, transformations, shapes and volumes.

However, in the destructor of FairRunAna, we still have manual control of its geometry object removals:

FairRunAna::~FairRunAna()
{
// delete fFriendFileList;
delete fField;
if (gGeoManager) {
if (gROOT->GetVersionInt() >= 60602) {
gGeoManager->GetListOfVolumes()->Delete();
gGeoManager->GetListOfShapes()->Delete();
}
delete gGeoManager;
}
if (fgRinstance == this) {
// Do not point to a destructed object!
fgRinstance = nullptr;
}
}

Solution

Please delete everything related to gGeoManager in the FairRunAna's destructor.

Edit: Any forms of deletion should be managed by a clear ownership and RAII.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions