 |
ATLAS Offline Software
|
Go to the documentation of this file.
17 #include "GaudiKernel/INamedInterface.h"
18 #include "GaudiKernel/EventContext.h"
43 typedef std::lock_guard<std::mutex>
lock_t;
47 #if defined(__linux__) && ( defined(__i386__) || defined(__x86_64__) )
63 ISvcLocator* pSvcLocator ) :
70 "Flag to configure, how many stack traces in case of FPE are printed. "
71 "Default: Zero, just report that FPE has happened. "
72 "After collecting the stacktrace, the code has to modify the mcontext_t "
73 "struct to ignore FPEs for the rest of the processing of the algorithm/service "
74 "This part is highly non-portable!" );
76 declareProperty(
"Nstacklines",
m_Nstacklines,
"Limit how deep we dive into the stack");
97 return StatusCode::SUCCESS;
113 return StatusCode::SUCCESS;
122 ATH_MSG_WARNING(
"Collecting stack traces for FPES is not supported on aarch64");
127 struct sigaction act;
128 memset(&act, 0,
sizeof act);
129 act.sa_sigaction = FPEAudit::fpe_sig_action;
130 act.sa_flags = SA_SIGINFO;
131 if ( sigaction(SIGFPE, &act, &FPEAudit::s_oldactHandler) != 0 )
133 ATH_MSG_WARNING (
"Printing stacktraces on FPE requested, but unable to install signal handler ! Switched off !");
139 FPEAudit::unmask_fpe();
154 feclearexcept(FE_ALL_EXCEPT);
156 FPEAudit::mask_fpe();
199 const std::string& caller,
200 const EventContext& ctx)
203 int raised = fetestexcept(FE_OVERFLOW | FE_INVALID | FE_DIVBYZERO);
205 std::stringstream evStr;
207 evStr <<
" on event " << ctx.eventID().event_number();
210 if (raised & FE_OVERFLOW) {
221 this->
msg(
MSG::INFO) <<
"FPE stacktrace " << j <<
" :\n";
228 if (raised & FE_INVALID) {
240 this->
msg(
MSG::INFO) <<
"FPE stacktrace " << j <<
" :\n";
246 if (raised & FE_DIVBYZERO) {
257 this->
msg(
MSG::INFO) <<
"FPE stacktrace " << j <<
" :\n";
271 fprintf(
stderr,
"too many SIGFPE detected, will be uninstalling signal handler\n");
281 int raised = fetestexcept(FE_OVERFLOW | FE_INVALID | FE_DIVBYZERO);
285 feclearexcept(FE_ALL_EXCEPT);
294 FPEAudit::mask_fpe();
303 throw std::runtime_error(
"inconsistent fpe-stack");
315 FPEAudit::unmask_fpe();
def resolve(tag)
utility functions
void add_fpe_node()
add an fpe node
std::atomic< int > m_nexceptions
virtual void after(const std::string &event, const std::string &name, const EventContext &ctx, const StatusCode &sc) override
std::lock_guard< std::mutex > lock_t
virtual ~FPEAuditor()
Destructor.
std::atomic< bool > s_handlerDisabled
POOL::TEvent event(POOL::TEvent::kClassAccess)
void pop_fpe_node()
pop an fpe node
::StatusCode StatusCode
StatusCode definition for legacy code.
void report_fpe(const std::string &step, const std::string &caller, const EventContext &ctx)
report fpes which happened during step 'step' on behalf of 'caller'
std::list< FpeNode_t > FpeStack_t
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
virtual void before(const std::string &event, const std::string &name, const EventContext &ctx) override
Auditor hooks.
#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]