ATLAS Offline Software
CoreDumpSvc.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ATHENASERVICES_COREDUMPSVC_H
6 #define ATHENASERVICES_COREDUMPSVC_H 1
7 
8 // System includes
9 #include <signal.h>
10 #include <string>
11 #include <atomic>
12 #include <tbb/concurrent_unordered_map.h>
13 
14 // Package includes
16 
17 // FrameWork includes
20 #include "GaudiKernel/IIncidentListener.h"
21 #include "EventInfo/EventID.h"
22 
23 
24 // Forward declarations
25 template <class TYPE> class SvcFactory;
26 
27 namespace CoreDumpSvcHandler {
28  void action ATLAS_NOT_THREAD_SAFE ( int sig, siginfo_t *info, void* extra );
29 }
30 
44 class CoreDumpSvc : public extends<AthService,
45  ICoreDumpSvc,
46  IIncidentListener> {
47 
48 protected:
49  friend void CoreDumpSvcHandler::action( int sig, siginfo_t *info, void* extra );
50 
53 
54 public:
55 
57  CoreDumpSvc( const std::string& name, ISvcLocator* pSvcLocator ) ATLAS_CTORDTOR_NOT_THREAD_SAFE;
58 
61 
63 
64  virtual void setCoreDumpInfo( const std::string& name, const std::string& value ) override;
66 
68  virtual void setCoreDumpInfo( const EventContext& ctx, const std::string& name, const std::string& value ) override;
69 
71  virtual std::string dump() const override;
73 
74 
76 
78  virtual StatusCode start() override;
80 
82  virtual void handle( const Incident& incident ) override;
84 
85 
86 private:
87  struct sysDumpRec{
88  std::string LastInc;
89  std::string EvId;
90  };
91  typedef tbb::concurrent_unordered_map<std::string,std::string > UserCore_t;
92  std::vector<UserCore_t> m_usrCoreDumps;
93  std::vector<sysDumpRec> m_sysCoreDumps;
94  siginfo_t* m_siginfo{nullptr};
95  std::atomic<EventID::event_number_t> m_eventCounter{0};
96 
97  thread_local static std::vector<uint8_t> s_stack;
98 
100 
101  Gaudi::Property<std::vector<int>> m_signals{this, "Signals", {SIGSEGV,SIGBUS,SIGILL,SIGFPE,SIGALRM},
102  "List of signals to catch"};
103 
104  Gaudi::Property<bool> m_callOldHandler{this, "CallOldHandler", true,
105  "Call previous signal handler"};
106 
107  Gaudi::Property<bool> m_dumpCoreFile{this, "DumpCoreFile", false,
108  "Produce a core dump file if resource limits (ulimit -c) allow"};
109 
110  Gaudi::Property<bool> m_stackTrace{this, "StackTrace", false,
111  "Produce (gdb) stack trace on crash. Useful if no other signal handler is used"};
112 
113  Gaudi::Property<bool> m_fastStackTrace{this, "FastStackTrace", false,
114  "Produce fast stack trace of current thread"};
115 
116  Gaudi::Property<std::string> m_coreDumpStream{this, "CoreDumpStream", "stdout",
117  "Stream to use for core dump [stdout,stderr]"};
118 
119  Gaudi::Property<int> m_fatalHandlerFlags{this, "FatalHandler", 0,
120  "Flags given to the fatal handler this service installs\n"
121  "if the flag is zero, no additional fatal handler is installed."};
122 
123  Gaudi::Property<double> m_timeout{this, "TimeOut", 30.0*60*1e9,
124  "Terminate job after it this reaches the time out in Wallclock time, "
125  "usually due to hanging during stack unwinding. Timeout given in nanoseconds despite seconds precision"};
126 
127  Gaudi::Property<bool> m_killOnSigInt{this, "KillOnSigInt",true, "Terminate job on SIGINT (aka Ctrl-C)"};
128 
129 
131 
133  void propertyHandler ATLAS_NOT_THREAD_SAFE (Gaudi::Details::PropertyBase& p);
134 
137 
140 
142  StatusCode installSignalHandler ATLAS_NOT_THREAD_SAFE ();
143 
145  StatusCode uninstallSignalHandler ATLAS_NOT_THREAD_SAFE ();
146 
148  void setAltStack();
149 };
150 
151 
152 #endif
grepfile.info
info
Definition: grepfile.py:38
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:50
CoreDumpSvc::sysDumpRec::EvId
std::string EvId
Definition: CoreDumpSvc.h:89
CoreDumpSvc::sysDumpRec::LastInc
std::string LastInc
Definition: CoreDumpSvc.h:88
CoreDumpSvc::start
virtual StatusCode start() override
Definition: CoreDumpSvc.cxx:337
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
siginfo_t
Definition: SealSignal.h:77
CoreDumpSvc::m_fastStackTrace
Gaudi::Property< bool > m_fastStackTrace
Definition: CoreDumpSvc.h:113
CoreDumpSvc::ATLAS_NOT_THREAD_SAFE
StatusCode installSignalHandler ATLAS_NOT_THREAD_SAFE()
Install signal handlers.
CoreDumpSvc::m_sysCoreDumps
std::vector< sysDumpRec > m_sysCoreDumps
Core dump info collected by this service
Definition: CoreDumpSvc.h:93
initialize
void initialize()
Definition: run_EoverP.cxx:894
SvcFactory
Definition: AthCnvSvc.h:28
CoreDumpSvc::m_callOldHandler
Gaudi::Property< bool > m_callOldHandler
Definition: CoreDumpSvc.h:104
CoreDumpSvc::~CoreDumpSvc
virtual ~CoreDumpSvc() ATLAS_CTORDTOR_NOT_THREAD_SAFE
Destructor.
Definition: CoreDumpSvc.cxx:254
CoreDumpSvc::m_coreDumpStream
Gaudi::Property< std::string > m_coreDumpStream
Definition: CoreDumpSvc.h:116
athena.value
value
Definition: athena.py:124
CoreDumpSvc::ATLAS_NOT_THREAD_SAFE
virtual StatusCode initialize ATLAS_NOT_THREAD_SAFE() override
CoreDumpSvc::setAltStack
void setAltStack()
Set up an alternate stack for the current thread.
Definition: CoreDumpSvc.cxx:647
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
CoreDumpSvc::m_eventCounter
std::atomic< EventID::event_number_t > m_eventCounter
Event counter.
Definition: CoreDumpSvc.h:95
CoreDumpSvc::UserCore_t
tbb::concurrent_unordered_map< std::string, std::string > UserCore_t
Definition: CoreDumpSvc.h:91
CoreDumpSvc::ATLAS_NOT_THREAD_SAFE
void propertyHandler ATLAS_NOT_THREAD_SAFE(Gaudi::Details::PropertyBase &p)
Property handler.
CoreDumpSvc::ATLAS_NOT_THREAD_SAFE
void print ATLAS_NOT_THREAD_SAFE()
Print core dump records to configured stream.
CoreDumpSvc::setCoreDumpInfo
virtual void setCoreDumpInfo(const std::string &name, const std::string &value) override
Set a name/value pair in the core dump record.
Definition: CoreDumpSvc.cxx:364
CoreDumpSvc
Service to print additional information before a crash.
Definition: CoreDumpSvc.h:46
CoreDumpSvc::sysDumpRec
Definition: CoreDumpSvc.h:87
EventID.h
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
CoreDumpSvc::m_timeout
Gaudi::Property< double > m_timeout
Definition: CoreDumpSvc.h:123
CoreDumpSvc::m_siginfo
siginfo_t * m_siginfo
Pointer to siginfo_t struct (set by signal handler)
Definition: CoreDumpSvc.h:94
CoreDumpSvcHandler::ATLAS_NOT_THREAD_SAFE
std::ostream &log ATLAS_NOT_THREAD_SAFE()
convenience method for logging
Definition: CoreDumpSvc.cxx:89
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
python.BuildSignatureFlags.sig
sig
Definition: BuildSignatureFlags.py:219
CoreDumpSvc::CoreDumpSvc
CoreDumpSvc()
Default constructor (do not use)
CoreDumpSvc::dump
virtual std::string dump() const override
Print all core dump records.
Definition: CoreDumpSvc.cxx:392
CoreDumpSvc::handle
virtual void handle(const Incident &incident) override
Incident listener.
Definition: CoreDumpSvc.cxx:552
CoreDumpSvc::setSigInfo
void setSigInfo(siginfo_t *info)
Set pointer to siginfo_t struct.
Definition: CoreDumpSvc.h:139
CoreDumpSvcHandler
Signal handler for CoreDumpSvc.
Definition: CoreDumpSvc.cxx:78
python.handimod.extra
int extra
Definition: handimod.py:522
CoreDumpSvc::m_signals
Gaudi::Property< std::vector< int > > m_signals
Alternate stack for signal handler.
Definition: CoreDumpSvc.h:101
CoreDumpSvc::m_dumpCoreFile
Gaudi::Property< bool > m_dumpCoreFile
Definition: CoreDumpSvc.h:107
private
#define private
Definition: DetDescrConditionsDict_dict_fixes.cxx:13
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
CoreDumpSvc::m_killOnSigInt
Gaudi::Property< bool > m_killOnSigInt
Definition: CoreDumpSvc.h:127
CoreDumpSvc::m_stackTrace
Gaudi::Property< bool > m_stackTrace
Definition: CoreDumpSvc.h:110
python.CaloScaleNoiseConfig.action
action
Definition: CaloScaleNoiseConfig.py:77
CoreDumpSvc::m_usrCoreDumps
std::vector< UserCore_t > m_usrCoreDumps
User defined core dump info.
Definition: CoreDumpSvc.h:92
AthService.h
ATLAS_CTORDTOR_NOT_THREAD_SAFE
#define ATLAS_CTORDTOR_NOT_THREAD_SAFE
Definition: checker_macros.h:213
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
ICoreDumpSvc.h
Interface of a core dump service.
CoreDumpSvc::s_stack
static thread_local std::vector< uint8_t > s_stack
Definition: CoreDumpSvc.h:97
checker_macros.h
Define macros for attributes used to control the static checker.
CoreDumpSvc::m_fatalHandlerFlags
Gaudi::Property< int > m_fatalHandlerFlags
Definition: CoreDumpSvc.h:119
CoreDumpSvc::ATLAS_NOT_THREAD_SAFE
StatusCode uninstallSignalHandler ATLAS_NOT_THREAD_SAFE()
Uninstall signal handlers.