21 #include "TInterpreter.h"
24 #include "TUnixSystem.h"
26 #include "TVirtualStreamerInfo.h"
29 #include "TClassTable.h"
40 static thread_local
bool s_ignoreWarnings =
false;
42 static bool s_ignoreEverything =
false;
44 void RootErrorHandlerImpl(
int level,
char const* location,
char const*
message) {
52 if (level >= kFatal) {
53 el_severity = SeverityLevel::kFatal;
54 }
else if (level >= kSysError) {
55 el_severity = SeverityLevel::kSysError;
56 }
else if (level >=
kError) {
62 if(s_ignoreEverything) {
73 if (message != 0) el_message =
message;
84 size_t index1 = el_message.find(precursor);
85 if (index1 != std::string::npos) {
86 size_t index2 = index1 + precursor.length();
87 size_t index3 = el_message.find_first_of(
" :", index2);
88 if (index3 != std::string::npos) {
89 size_t substrlen = index3-index2;
91 el_identifier += el_message.substr(index2,substrlen);
94 index1 = el_location.find(
"::");
95 if (index1 != std::string::npos) {
97 el_identifier += el_location.substr(0, index1);
103 if ((el_location.find(
"TBranchElement::Fill") != std::string::npos)
104 && (el_message.find(
"fill branch") != std::string::npos)
105 && (el_message.find(
"address") != std::string::npos)
106 && (el_message.find(
"not set") != std::string::npos)) {
107 el_severity = SeverityLevel::kFatal;
110 if ((el_message.find(
"Tree branches") != std::string::npos)
111 && (el_message.find(
"different numbers of entries") != std::string::npos)) {
112 el_severity = SeverityLevel::kFatal;
118 if ((el_message.find(
"no dictionary for class") != std::string::npos) ||
119 (el_message.find(
"already in TClassTable") != std::string::npos) ||
120 (el_message.find(
"matrix not positive definite") != std::string::npos) ||
121 (el_message.find(
"not a TStreamerInfo object") != std::string::npos) ||
122 (el_message.find(
"Problems declaring payload") != std::string::npos) ||
123 (el_location.find(
"Fit") != std::string::npos) ||
124 (el_location.find(
"TDecompChol::Solve") != std::string::npos) ||
125 (el_location.find(
"THistPainter::PaintInit") != std::string::npos) ||
126 (el_location.find(
"TUnixSystem::SetDisplay") != std::string::npos) ||
127 (el_location.find(
"TGClient::GetFontByName") != std::string::npos) ||
128 (el_message.find(
"nbins is <=0 - set to nbins = 1") != std::string::npos) ||
129 (el_message.find(
"nbinsy is <=0 - set to nbinsy = 1") != std::string::npos) ||
131 (el_location.find(
"CINTTypedefBuilder::Setup")!= std::string::npos) and
132 (el_message.find(
"possible entries are in use!") != std::string::npos))) {
148 if (die && (el_location !=
std::string(
"@SUB=TUnixSystem::DispatchSignals"))) {
149 std::ostringstream sstr;
150 sstr <<
"Fatal Root Error: " << el_location <<
"\n" << el_message <<
'\n';
153 except.clearMessage();
161 if (el_severity == SeverityLevel::kFatal) {
163 }
else if (el_severity == SeverityLevel::kSysError) {
170 edm::LogInfo(
"Root_Information") << el_location << el_message ;
174 void RootErrorHandler(
int level,
bool,
char const* location,
char const* message) {
175 RootErrorHandlerImpl(level, location, message);
179 void sig_dostack_then_abort(
int sig,siginfo_t*,
void*) {
181 const char* signalname =
"unknown";
184 signalname =
"bus error";
187 signalname =
"segmentation violation";
190 signalname =
"illegal instruction";
194 edm::LogError(
"FatalSystemSignal")<<
"A fatal system signal has occurred: "<<signalname;
195 std::cerr<<
"\n\nA fatal system signal has occurred: "<<signalname<<
"\n"
196 <<
"The following is the call stack containing the origin of the signal.\n"
197 <<
"NOTE:The first few functions on the stack are artifacts of processing the signal and can be ignored\n\n";
199 gSystem->StackTrace();
200 std::cerr<<
"\nA fatal system signal has occurred: "<<signalname<<
"\n";
205 void sig_abort(
int sig, siginfo_t*,
void*) {
215 unloadSigHandler_(pset.getUntrackedParameter<bool> (
"UnloadRootSigHandler")),
216 resetErrHandler_(pset.getUntrackedParameter<bool> (
"ResetRootErrHandler")),
217 loadAllDictionaries_(pset.getUntrackedParameter<bool>(
"LoadAllDictionaries")),
218 autoLibraryLoader_(loadAllDictionaries_
or pset.getUntrackedParameter<bool> (
"AutoLibraryLoader"))
223 gSystem->ResetSignal(kSigChild);
224 gSystem->ResetSignal(kSigBus);
225 gSystem->ResetSignal(kSigSegmentationViolation);
226 gSystem->ResetSignal(kSigIllegalInstruction);
227 gSystem->ResetSignal(kSigSystem);
228 gSystem->ResetSignal(kSigPipe);
229 gSystem->ResetSignal(kSigAlarm);
230 gSystem->ResetSignal(kSigUrgent);
231 gSystem->ResetSignal(kSigFloatingException);
232 gSystem->ResetSignal(kSigWindowChanged);
236 gSystem->ResetSignal(kSigBus);
237 gSystem->ResetSignal(kSigSegmentationViolation);
238 gSystem->ResetSignal(kSigIllegalInstruction);
256 SetErrorHandler(RootErrorHandler);
261 gInterpreter->SetClassAutoloading(1);
265 TTree::SetMaxTreeSize(kMaxLong64);
266 TH1::AddDirectory(kFALSE);
273 if (!
hasDictionary(
typeid(std::vector<std::vector<unsigned int> >))) {
285 TIter
iter(gROOT->GetListOfFiles());
286 TObject *
obj =
nullptr;
287 while(
nullptr != (obj =
iter.Next())) {
288 TFile*
f =
dynamic_cast<TFile*
>(
obj);
293 iter = TIter(gROOT->GetListOfFiles());
300 TThread::Initialize();
302 TObject::SetObjectStat(
false);
305 TVirtualStreamerInfo::Optimize(
false);
309 static thread_local TThread guard;
314 desc.
setComment(
"Centralized interface to ROOT.");
316 ->setComment(
"If True, signals are handled by this service, rather than by ROOT.");
318 ->setComment(
"If True, ROOT messages (e.g. errors, warnings) are handled by this service, rather than by ROOT.");
320 ->setComment(
"If True, enables automatic loading of data dictionaries.");
322 ->setComment(
"If True, loads all ROOT dictionaries.");
324 ->setComment(
"If True, do an abort when a signal occurs that causes a crash. If False, ROOT will do an exit which attempts to do a clean shutdown.");
326 ->setComment(
"Sets ROOT's gDebug value.");
327 descriptions.
add(
"InitRootHandlers", desc);
332 s_ignoreWarnings =
false;
337 s_ignoreWarnings =
true;
T getUntrackedParameter(std::string const &, T const &) const
virtual void enableWarnings_() override
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
void setRefCoreStreamer(bool resetAll=false)
std::string const & dictionaryPlugInPrefix()
void installCustomHandler(int signum, CFUNC func)
std::shared_ptr< const void > sigSegvHandler_
std::shared_ptr< const void > sigBusHandler_
void setComment(std::string const &value)
std::shared_ptr< const void > sigIllHandler_
virtual void initializeThisThreadForUse() override
virtual void ignoreWarnings_() override
void addAdditionalInfo(std::string const &info)
static PluginCapabilities * get()
InitRootHandlers(ParameterSet const &pset)
virtual ~InitRootHandlers()
void add(std::string const &label, ParameterSetDescription const &psetDescription)
virtual void willBeUsingThreads() override
static void fillDescriptions(ConfigurationDescriptions &descriptions)
bool hasDictionary(std::type_info const &)
void load(const std::string &iName)