Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
YanzhaoW opened this issue Jan 22, 2025 · 0 comments
Open

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

YanzhaoW opened this issue Jan 22, 2025 · 0 comments

Comments

@YanzhaoW
Copy link

YanzhaoW commented Jan 22, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant