Skip to content
Snippets Groups Projects
Commit b7737780 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

CoreDumpSvc: Add StackTrace property

Add a boolean `StackTrace` property (default: `False`) that will create
a stack trace using ROOT's stack trace generator (usually invoking
`gdb`). This is useful for cases where there is no default signal handler
doing this, or if for some reason the signal handler is not usable
(ATR-20918). For a regular athena job this should not be necessary. If
used anyway, one should set `CallOlderHanlder = False` to avoid multiple
stack trace generations.
parent dd08934d
No related branches found
No related tags found
7 merge requests!58791DataQualityConfigurations: Modify L1Calo config for web display,!46784MuonCondInterface: Enable thread-safety checking.,!46776Updated LArMonitoring config file for WD to match new files produced using MT,!45405updated ART test cron job,!42417Draft: DIRE and VINCIA Base Fragments for Pythia 8.3,!30573CoreDumpSvc: Add StackTrace property (second try),!30485CoreDumpSvc: Add StackTrace property
...@@ -28,6 +28,9 @@ ...@@ -28,6 +28,9 @@
#include "CoreDumpSvc.h" #include "CoreDumpSvc.h"
#include "SetFatalHandler.h" #include "SetFatalHandler.h"
// ROOT includes
#include "TSystem.h"
// Gaudi includes // Gaudi includes
#include "GaudiKernel/Property.h" #include "GaudiKernel/Property.h"
#include "GaudiKernel/IAlgorithm.h" #include "GaudiKernel/IAlgorithm.h"
...@@ -59,9 +62,10 @@ namespace CoreDumpSvcHandler ...@@ -59,9 +62,10 @@ namespace CoreDumpSvcHandler
{ {
typedef std::map<int, struct sigaction> SigHandler_t; typedef std::map<int, struct sigaction> SigHandler_t;
SigHandler_t oldSigHandler; ///< old signal handlers SigHandler_t oldSigHandler; ///< old signal handlers
bool callOldHandler(true); ///< forward calls to old handlers? bool callOldHandler(true); ///< forward calls to old handlers?
CoreDumpSvc* coreDumpSvc(nullptr); ///< pointer to CoreDumpSvc bool stackTrace(false); ///< produce stack trace?
CoreDumpSvc* coreDumpSvc(nullptr); ///< pointer to CoreDumpSvc
/** /**
* Signal handler for the CoreDumpSvc * Signal handler for the CoreDumpSvc
...@@ -93,6 +97,11 @@ namespace CoreDumpSvcHandler ...@@ -93,6 +97,11 @@ namespace CoreDumpSvcHandler
coreDumpSvc->print(); coreDumpSvc->print();
} }
if (gSystem && stackTrace) {
std::cout << "Producing stack trace..." << std::endl;
gSystem->StackTrace();
}
if (callOldHandler) { if (callOldHandler) {
// Call previous signal handler // Call previous signal handler
// Need to distinguish between the two different types // Need to distinguish between the two different types
...@@ -130,6 +139,7 @@ CoreDumpSvc::CoreDumpSvc( const std::string& name, ISvcLocator* pSvcLocator ) : ...@@ -130,6 +139,7 @@ CoreDumpSvc::CoreDumpSvc( const std::string& name, ISvcLocator* pSvcLocator ) :
CoreDumpSvcHandler::coreDumpSvc = this; CoreDumpSvcHandler::coreDumpSvc = this;
m_callOldHandler.declareUpdateHandler(&CoreDumpSvc::propertyHandler, this); m_callOldHandler.declareUpdateHandler(&CoreDumpSvc::propertyHandler, this);
m_stackTrace.declareUpdateHandler(&CoreDumpSvc::propertyHandler, this);
m_coreDumpStream.declareUpdateHandler(&CoreDumpSvc::propertyHandler, this); m_coreDumpStream.declareUpdateHandler(&CoreDumpSvc::propertyHandler, this);
m_fatalHandlerFlags.declareUpdateHandler(&CoreDumpSvc::propertyHandler, this); m_fatalHandlerFlags.declareUpdateHandler(&CoreDumpSvc::propertyHandler, this);
...@@ -146,6 +156,7 @@ CoreDumpSvc::~CoreDumpSvc() ...@@ -146,6 +156,7 @@ CoreDumpSvc::~CoreDumpSvc()
void CoreDumpSvc::propertyHandler(Property& p) void CoreDumpSvc::propertyHandler(Property& p)
{ {
CoreDumpSvcHandler::callOldHandler = m_callOldHandler; CoreDumpSvcHandler::callOldHandler = m_callOldHandler;
CoreDumpSvcHandler::stackTrace = m_stackTrace;
if ( p.name()==m_coreDumpStream.name() ) { if ( p.name()==m_coreDumpStream.name() ) {
const std::string val = p.toString(); const std::string val = p.toString();
......
/* /*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/ */
#ifndef ATHENASERVICES_COREDUMPSVC_H #ifndef ATHENASERVICES_COREDUMPSVC_H
...@@ -102,9 +102,12 @@ private: ...@@ -102,9 +102,12 @@ private:
Gaudi::Property<std::vector<int>> m_signals{this, "Signals", {SIGSEGV,SIGBUS,SIGILL,SIGFPE}, Gaudi::Property<std::vector<int>> m_signals{this, "Signals", {SIGSEGV,SIGBUS,SIGILL,SIGFPE},
"List of signals to catch"}; "List of signals to catch"};
Gaudi::Property<bool> m_callOldHandler{this, "CallOldHandler", true, Gaudi::Property<bool> m_callOldHandler{this, "CallOldHandler", true,
"Call previous signal handler"}; "Call previous signal handler"};
Gaudi::Property<bool> m_stackTrace{this, "StackTrace", false,
"Produce stack trace on crash. Useful if no other signal handler is used"};
Gaudi::Property<std::string> m_coreDumpStream{this, "CoreDumpStream", "stdout", Gaudi::Property<std::string> m_coreDumpStream{this, "CoreDumpStream", "stdout",
"Stream to use for core dump [stdout,stderr,MsgStream]"}; "Stream to use for core dump [stdout,stderr,MsgStream]"};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment