From 90c18b83b18d3b1a26f57eb0a9aae8236168bce3 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Tue, 15 Sep 2026 04:29:41 +0200 Subject: [PATCH] Properly handle object lifetime Taking ownership of DPL provided objects is wrong. --- Modules/CTP/include/CTP/RawDataQcTask.h | 2 +- Modules/CTP/src/RawDataQcTask.cxx | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Modules/CTP/include/CTP/RawDataQcTask.h b/Modules/CTP/include/CTP/RawDataQcTask.h index 84a18e3a65..6caa76949b 100644 --- a/Modules/CTP/include/CTP/RawDataQcTask.h +++ b/Modules/CTP/include/CTP/RawDataQcTask.h @@ -79,7 +79,7 @@ class CTPRawDataReaderTask final : public TaskInterface int mIndexMBclass = -1; // index for the MB ctp class, which is used as scaling for the ratios bool mConsistCheck = 0; bool mReadCTPconfigInMonitorData = 0; - const o2::ctp::CTPConfiguration* mCTPconfig = nullptr; + bool mCTPconfigFound = false; // the config is copied out on the first timeframe that has one std::string mMBclassName; std::array mClassErrorsA; bool mPerformConsistencyCheck = false; diff --git a/Modules/CTP/src/RawDataQcTask.cxx b/Modules/CTP/src/RawDataQcTask.cxx index 6985f3d9f7..2226235bac 100644 --- a/Modules/CTP/src/RawDataQcTask.cxx +++ b/Modules/CTP/src/RawDataQcTask.cxx @@ -304,12 +304,15 @@ void CTPRawDataReaderTask::monitorData(o2::framework::ProcessingContext& ctx) std::vector outputDigits; if (mReadCTPconfigInMonitorData) { - if (mCTPconfig == nullptr) { - mCTPconfig = ctx.inputs().get("ctp-config").get(); - // mCTPconfig = ctpConfigPtr.get(); - if (mCTPconfig != nullptr) { + if (!mCTPconfigFound) { + // Not kept beyond this scope: the object belongs to the framework's CCDB + // cache and may be replaced on the next validity period. Everything we + // need is copied out below. + auto ctpConfig = ctx.inputs().get("ctp-config"); + if (ctpConfig != nullptr) { + mCTPconfigFound = true; ILOG(Info, Support) << "CTP config found" << ENDM; - std::vector ctpcls = mCTPconfig->getCTPClasses(); + std::vector ctpcls = ctpConfig->getCTPClasses(); for (size_t i = 0; i < ctpcls.size(); i++) { classNames[i] = ctpcls[i].name.c_str(); if (ctpcls[i].name.find(mMBclassName) != std::string::npos) { @@ -317,7 +320,7 @@ void CTPRawDataReaderTask::monitorData(o2::framework::ProcessingContext& ctx) break; } } - mDecoder.setCTPConfig(*mCTPconfig); + mDecoder.setCTPConfig(*ctpConfig); } } for (int i = 0; i < nclasses; i++) {