From 5d72aa5a10e8ad75dd45fb6a7bb9fd524ea9fd8e Mon Sep 17 00:00:00 2001 From: P-A Loizeau <p.-a.loizeau@gsi.de> Date: Thu, 19 Oct 2023 14:34:38 +0200 Subject: [PATCH] Fix segfault with FS+FR dev (nov22 v18.8.x) at end of run_unpack macros exec --- macro/run/run_unpack_online.C | 7 +++---- macro/run/run_unpack_online_bmon.C | 7 +++---- macro/run/run_unpack_tsa.C | 7 +++---- macro/run/run_unpack_tsa_bmon.C | 7 +++---- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/macro/run/run_unpack_online.C b/macro/run/run_unpack_online.C index 67ee880222..2acf1e6666 100644 --- a/macro/run/run_unpack_online.C +++ b/macro/run/run_unpack_online.C @@ -451,7 +451,7 @@ void run_unpack_online(std::vector<std::string> publisher = {"tcp://localhost:55 // ------------------------------------------------------------------------ // ----- CbmSourceTsArchive ------------------------------------------- - auto source = new CbmSourceTsArchive(publisher); + std::unique_ptr<CbmSourceTsArchive> source = std::unique_ptr<CbmSourceTsArchive>(new CbmSourceTsArchive(publisher)); auto unpack = source->GetRecoUnpack(); unpack->SetDoPerfProfiling(doPerfProfiling); unpack->SetOutputFilename(perfProfFileName); @@ -471,7 +471,7 @@ void run_unpack_online(std::vector<std::string> publisher = {"tcp://localhost:55 // ----- FairRunAna --------------------------------------------------- - auto run = new FairRunOnline(source); + auto run = new FairRunOnline(source.release()); auto sink = new FairRootFileSink(outfilename.data()); run->SetSink(sink); auto eventheader = new CbmTsEventHeader(); @@ -516,11 +516,10 @@ void run_unpack_online(std::vector<std::string> publisher = {"tcp://localhost:55 // ------------------------------------------------------------------------ // -- Release all shared pointers to config before ROOT destroys things - - // => We need to destroy things by hand because run->Finish calls (trhought the FairRootManager) Source->Close which + // => We need to destroy things by hand because run->Finish calls (through the FairRootManager) Source->Close which // does call the Source destructor, so due to share pointer things stay alive until out of macro scope... run->SetSource(nullptr); delete run; - delete source; bmonconfig.reset(); stsconfig.reset(); diff --git a/macro/run/run_unpack_online_bmon.C b/macro/run/run_unpack_online_bmon.C index 65aa2a8c20..fdcee3ddee 100644 --- a/macro/run/run_unpack_online_bmon.C +++ b/macro/run/run_unpack_online_bmon.C @@ -124,7 +124,7 @@ void run_unpack_online_bmon(std::vector<std::string> publisher = {"tcp://localho // ------------------------------------------------------------------------ // ----- CbmSourceTsArchive ------------------------------------------- - auto source = new CbmSourceTsArchive(publisher); + std::unique_ptr<CbmSourceTsArchive> source = std::unique_ptr<CbmSourceTsArchive>(new CbmSourceTsArchive(publisher)); auto unpack = source->GetRecoUnpack(); //unpack->SetDoPerfProfiling(doPerfProfiling); //unpack->SetOutputFilename(perfProfFileName); @@ -137,7 +137,7 @@ void run_unpack_online_bmon(std::vector<std::string> publisher = {"tcp://localho // ----- FairRunAna --------------------------------------------------- - auto run = new FairRunOnline(source); + auto run = new FairRunOnline(source.release()); auto sink = new FairRootFileSink(outfilename.data()); run->SetSink(sink); auto eventheader = new CbmTsEventHeader(); @@ -182,11 +182,10 @@ void run_unpack_online_bmon(std::vector<std::string> publisher = {"tcp://localho // ------------------------------------------------------------------------ // -- Release all shared pointers to config before ROOT destroys things - - // => We need to destroy things by hand because run->Finish calls (trhought the FairRootManager) Source->Close which + // => We need to destroy things by hand because run->Finish calls (through the FairRootManager) Source->Close which // does call the Source destructor, so due to share pointer things stay alive until out of macro scope... run->SetSource(nullptr); delete run; - delete source; bmonconfig.reset(); // ------------------------------------------------------------------------ diff --git a/macro/run/run_unpack_tsa.C b/macro/run/run_unpack_tsa.C index c8128016ed..1b81888a8d 100644 --- a/macro/run/run_unpack_tsa.C +++ b/macro/run/run_unpack_tsa.C @@ -464,7 +464,7 @@ void run_unpack_tsa(std::vector<std::string> infile = {"test.tsa"}, UInt_t runid // ------------------------------------------------------------------------ // ----- CbmSourceTsArchive ------------------------------------------- - auto source = new CbmSourceTsArchive(infile); + std::unique_ptr<CbmSourceTsArchive> source = std::unique_ptr<CbmSourceTsArchive>(new CbmSourceTsArchive(infile)); auto unpack = source->GetRecoUnpack(); unpack->SetDoPerfProfiling(doPerfProfiling); /// Uncomment following line to enable extra hists about unpacker and detectors performances (I/O, I/O shares, expan.) @@ -487,7 +487,7 @@ void run_unpack_tsa(std::vector<std::string> infile = {"test.tsa"}, UInt_t runid // ----- FairRunAna --------------------------------------------------- - auto run = new FairRunOnline(source); + auto run = new FairRunOnline(source.release()); auto sink = new FairRootFileSink(outfilename.data()); run->SetSink(sink); auto eventheader = new CbmTsEventHeader(); @@ -525,11 +525,10 @@ void run_unpack_tsa(std::vector<std::string> infile = {"test.tsa"}, UInt_t runid // ------------------------------------------------------------------------ // -- Release all shared pointers to config before ROOT destroys things - - // => We need to destroy things by hand because run->Finish calls (trhought the FairRootManager) Source->Close which + // => We need to destroy things by hand because run->Finish calls (through the FairRootManager) Source->Close which // does call the Source destructor, so due to share pointer things stay alive until out of macro scope... run->SetSource(nullptr); delete run; - delete source; bmonconfig.reset(); stsconfig.reset(); diff --git a/macro/run/run_unpack_tsa_bmon.C b/macro/run/run_unpack_tsa_bmon.C index 2479bdf3b6..7da33d24e5 100644 --- a/macro/run/run_unpack_tsa_bmon.C +++ b/macro/run/run_unpack_tsa_bmon.C @@ -137,7 +137,7 @@ void run_unpack_tsa_bmon(std::vector<std::string> infile = {"test.tsa"}, UInt_t // ------------------------------------------------------------------------ // ----- CbmSourceTsArchive ------------------------------------------- - auto source = new CbmSourceTsArchive(infile); + std::unique_ptr<CbmSourceTsArchive> source = std::unique_ptr<CbmSourceTsArchive>(new CbmSourceTsArchive(infile)); auto unpack = source->GetRecoUnpack(); unpack->SetDoPerfProfiling(doPerfProfiling); unpack->SetOutputFilename(perfProfFileName); @@ -148,7 +148,7 @@ void run_unpack_tsa_bmon(std::vector<std::string> infile = {"test.tsa"}, UInt_t // ------------------------------------------------------------------------ // ----- FairRunAna --------------------------------------------------- - auto run = new FairRunOnline(source); + auto run = new FairRunOnline(source.release()); auto sink = new FairRootFileSink(outfilename.data()); run->SetSink(sink); auto eventheader = new CbmTsEventHeader(); @@ -186,11 +186,10 @@ void run_unpack_tsa_bmon(std::vector<std::string> infile = {"test.tsa"}, UInt_t // ------------------------------------------------------------------------ // -- Release all shared pointers to config before ROOT destroys things - - // => We need to destroy things by hand because run->Finish calls (trhought the FairRootManager) Source->Close which + // => We need to destroy things by hand because run->Finish calls (through the FairRootManager) Source->Close which // does call the Source destructor, so due to share pointer things stay alive until out of macro scope... run->SetSource(nullptr); delete run; - delete source; bmonconfig.reset(); // ------------------------------------------------------------------------ -- GitLab