|
ATLAS Offline Software
|
Go to the documentation of this file.
17 #include "GaudiKernel/INamedInterface.h"
18 #include "GaudiKernel/EventContext.h"
19 #include "GaudiKernel/ThreadLocalContext.h"
44 typedef std::lock_guard<std::mutex>
lock_t;
48 #if defined(__linux__) && ( defined(__i386__) || defined(__x86_64__) )
64 ISvcLocator* pSvcLocator ) :
71 "Flag to configure, how many stack traces in case of FPE are printed. "
72 "Default: Zero, just report that FPE has happened. "
73 "After collecting the stacktrace, the code has to modify the mcontext_t "
74 "struct to ignore FPEs for the rest of the processing of the algorithm/service "
75 "This part is highly non-portable!" );
77 declareProperty(
"Nstacklines",
m_Nstacklines,
"Limit how deep we dive into the stack");
98 return StatusCode::SUCCESS;
114 return StatusCode::SUCCESS;
123 ATH_MSG_WARNING(
"Collecting stack traces for FPES is not supported on aarch64");
128 struct sigaction act;
129 memset(&act, 0,
sizeof act);
130 act.sa_sigaction = FPEAudit::fpe_sig_action;
131 act.sa_flags = SA_SIGINFO;
132 if ( sigaction(SIGFPE, &act, &FPEAudit::s_oldactHandler) != 0 )
134 ATH_MSG_WARNING (
"Printing stacktraces on FPE requested, but unable to install signal handler ! Switched off !");
140 FPEAudit::unmask_fpe();
155 feclearexcept(FE_ALL_EXCEPT);
157 FPEAudit::mask_fpe();
201 const std::string& caller,
212 const std::string& caller)
215 int raised = fetestexcept(FE_OVERFLOW | FE_INVALID | FE_DIVBYZERO);
218 std::stringstream evStr;
219 const EventContext& ctx = Gaudi::Hive::currentContext();
221 evStr <<
" on event " << ctx.eventID().event_number();
224 if (raised & FE_OVERFLOW) {
235 this->
msg(MSG::INFO) <<
"FPE stacktrace " << j <<
" :\n";
242 if (raised & FE_INVALID) {
254 this->
msg(MSG::INFO) <<
"FPE stacktrace " << j <<
" :\n";
260 if (raised & FE_DIVBYZERO) {
271 this->
msg(MSG::INFO) <<
"FPE stacktrace " << j <<
" :\n";
285 fprintf(
stderr,
"too many SIGFPE detected, will be uninstalling signal handler\n");
295 int raised = fetestexcept(FE_OVERFLOW | FE_INVALID | FE_DIVBYZERO);
299 feclearexcept(FE_ALL_EXCEPT);
308 FPEAudit::mask_fpe();
317 throw std::runtime_error(
"inconsistent fpe-stack");
329 FPEAudit::unmask_fpe();
def resolve(tag)
utility functions
void add_fpe_node()
add an fpe node
virtual void before(StandardEventType evt, INamedInterface *comp) override
const char * toStr(SegmentationType e)
Transform enumeration types to string.
std::atomic< int > m_nexceptions
std::lock_guard< std::mutex > lock_t
virtual ~FPEAuditor()
Destructor.
void report_fpe(const std::string &step, const std::string &caller)
report fpes which happened during step 'step' on behalf of 'caller'
std::atomic< bool > s_handlerDisabled
void pop_fpe_node()
pop an fpe node
::StatusCode StatusCode
StatusCode definition for legacy code.
std::list< FpeNode_t > FpeStack_t
virtual void after(StandardEventType evt, INamedInterface *comp, const StatusCode &sc) override
std::atomic< bool > s_handlerInstalled
virtual StatusCode finalize() override
FPEAuditor(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
virtual StatusCode initialize() override
Gaudi hooks.
unsigned int m_Nstacklines
#define ATH_MSG_WARNING(x)
void * s_array_I[MAXARRAY]
void * s_array_D[MAXARRAY]
std::atomic< unsigned int > m_CountFPEs[FPEAUDITOR_ARRAYSIZE]
fenv_t m_env
The FP environment before we initialize.
static thread_local FpeStack_t s_fpe_stack
a stack of FPE exceptions which have been raised
thread_local FPEAuditTLSData s_tlsdata
struct sigaction s_oldactHandler ATLAS_THREAD_SAFE
Define macros for attributes used to control the static checker.
unsigned int m_NstacktracesOnFPE
void * s_array_O[MAXARRAY]