diff --git a/Control/AthenaServices/src/CoreDumpSvc.cxx b/Control/AthenaServices/src/CoreDumpSvc.cxx index 8465f7cf75ef8770bc6a2405c36a0ed0a9df86c8..944b4ea4e42111c57fcac7122c335e5149672076 100644 --- a/Control/AthenaServices/src/CoreDumpSvc.cxx +++ b/Control/AthenaServices/src/CoreDumpSvc.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ /** @@ -53,7 +53,7 @@ namespace { - const char* horizLine = "-------------------------------------------------------------------------------------\n"; + const char* const horizLine = "-------------------------------------------------------------------------------------\n"; void ExitOnInt( int sig, siginfo_t*, void* ) { if ( sig == SIGINT ) { @@ -85,12 +85,12 @@ namespace CoreDumpSvcHandler CoreDumpSvc* coreDumpSvc(nullptr); ///< pointer to CoreDumpSvc std::ostream* ostr(&std::cout); ///< stream for printing - std::ostream& log() { return *ostr; } ///< convenience method for logging + std::ostream& log ATLAS_NOT_THREAD_SAFE () { return *ostr; } ///< convenience method for logging /** * Signal handler for the CoreDumpSvc */ - void action( int sig, siginfo_t *info, void* extra ) + void action ATLAS_NOT_THREAD_SAFE ( int sig, siginfo_t *info, void* extra ) { // Careful: don't do anything here that might allocate memory. @@ -214,7 +214,7 @@ namespace CoreDumpSvcHandler //================================================================================ // C'tor, D'tor, Property handler //================================================================================ -CoreDumpSvc::CoreDumpSvc( const std::string& name, ISvcLocator* pSvcLocator ) : +CoreDumpSvc::CoreDumpSvc( const std::string& name, ISvcLocator* pSvcLocator ) : base_class( name, pSvcLocator ) { // Set us as the current instance @@ -354,7 +354,7 @@ void CoreDumpSvc::setCoreDumpInfo( const EventContext& ctx, const std::string& n //---------------------------------------------------------------------- // Print all core dump records //---------------------------------------------------------------------- -void CoreDumpSvc::print() +void CoreDumpSvc::print ATLAS_NOT_THREAD_SAFE () { ATH_MSG_FATAL("Caught fatal signal. Printing details to " << m_coreDumpStream.value() << "."); CoreDumpSvcHandler::log() << dump() << std::flush; @@ -366,11 +366,12 @@ void CoreDumpSvc::print() std::string CoreDumpSvc::dump() const { std::ostringstream os; + char buf[26]; const time_t now = time(nullptr); os << "-------------------------------------------------------------------------------------" << "\n"; os << "Core dump from " << name() << " on " << System::hostName() - << " at " << ctime(&now) /*<< "\n"*/; // ctime adds "\n" + << " at " << ctime_r(&now, buf) /*<< "\n"*/; // ctime adds "\n" os << "\n"; // Print additional information if available @@ -556,7 +557,7 @@ void CoreDumpSvc::handle(const Incident& incident) //---------------------------------------------------------------------- // Install signal handler //---------------------------------------------------------------------- -StatusCode CoreDumpSvc::installSignalHandler() +StatusCode CoreDumpSvc::installSignalHandler ATLAS_NOT_THREAD_SAFE () { ATH_MSG_DEBUG ("Installing signal handler"); std::ostringstream oss; @@ -594,7 +595,7 @@ StatusCode CoreDumpSvc::installSignalHandler() //---------------------------------------------------------------------- // Uninstall signal handler //---------------------------------------------------------------------- -StatusCode CoreDumpSvc::uninstallSignalHandler() +StatusCode CoreDumpSvc::uninstallSignalHandler ATLAS_NOT_THREAD_SAFE () { ATH_MSG_DEBUG ("Uninstalling signal handler"); diff --git a/Control/AthenaServices/src/CoreDumpSvc.h b/Control/AthenaServices/src/CoreDumpSvc.h index 535696aabd1a170690e30f06b0e69becfd52f30f..f4d96183b8c176b6c2ffe66a20cb9ce435e099ab 100644 --- a/Control/AthenaServices/src/CoreDumpSvc.h +++ b/Control/AthenaServices/src/CoreDumpSvc.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ #ifndef ATHENASERVICES_COREDUMPSVC_H @@ -16,6 +16,7 @@ // FrameWork includes #include "AthenaBaseComps/AthService.h" +#include "CxxUtils/checker_macros.h" #include "GaudiKernel/IIncidentListener.h" #include "EventInfo/EventID.h" @@ -24,7 +25,7 @@ template <class TYPE> class SvcFactory; namespace CoreDumpSvcHandler { - void action( int sig, siginfo_t *info, void* extra ); + void action ATLAS_NOT_THREAD_SAFE ( int sig, siginfo_t *info, void* extra ); } /** @@ -57,32 +58,32 @@ protected: public: /// Constructor with parameters - CoreDumpSvc( const std::string& name, ISvcLocator* pSvcLocator ); + CoreDumpSvc( const std::string& name, ISvcLocator* pSvcLocator ) ATLAS_CTORDTOR_NOT_THREAD_SAFE; /// Destructor - virtual ~CoreDumpSvc(); + virtual ~CoreDumpSvc() ATLAS_CTORDTOR_NOT_THREAD_SAFE; /// \name ICoreDumpSvc implementation //@{ /// Set a name/value pair in the core dump record - virtual void setCoreDumpInfo( const std::string& name, const std::string& value ); + virtual void setCoreDumpInfo( const std::string& name, const std::string& value ) override; /// Set a name/value pair in the core dump record for given EventContext - virtual void setCoreDumpInfo( const EventContext& ctx, const std::string& name, const std::string& value ); + virtual void setCoreDumpInfo( const EventContext& ctx, const std::string& name, const std::string& value ) override; /// Print all core dump records - virtual std::string dump() const; + virtual std::string dump() const override; //@} /// \name Gaudi implementation //@{ - virtual StatusCode initialize(); - virtual StatusCode start(); - virtual StatusCode finalize(); + virtual StatusCode initialize ATLAS_NOT_THREAD_SAFE () override; + virtual StatusCode start() override; + virtual StatusCode finalize ATLAS_NOT_THREAD_SAFE () override; /// Incident listener - virtual void handle( const Incident& incident ); + virtual void handle( const Incident& incident ) override; //@} @@ -130,19 +131,19 @@ private: ///@} /// Property handler - void propertyHandler(Gaudi::Details::PropertyBase& p); + void propertyHandler ATLAS_NOT_THREAD_SAFE (Gaudi::Details::PropertyBase& p); /// Print core dump records to configured stream - void print(); + void print ATLAS_NOT_THREAD_SAFE (); /// Set pointer to siginfo_t struct void setSigInfo(siginfo_t* info) { m_siginfo = info; } /// Install signal handlers - StatusCode installSignalHandler(); + StatusCode installSignalHandler ATLAS_NOT_THREAD_SAFE (); /// Uninstall signal handlers - StatusCode uninstallSignalHandler(); + StatusCode uninstallSignalHandler ATLAS_NOT_THREAD_SAFE (); /// Set up an alternate stack for the current thread. void setAltStack();