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_message.find(
"Announced number of args different from the real number of argument passed") != std::string::npos) ||
124 (el_location.find(
"Fit") != std::string::npos) ||
125 (el_location.find(
"TDecompChol::Solve") != std::string::npos) ||
126 (el_location.find(
"THistPainter::PaintInit") != std::string::npos) ||
127 (el_location.find(
"TUnixSystem::SetDisplay") != std::string::npos) ||
128 (el_location.find(
"TGClient::GetFontByName") != std::string::npos) ||
129 (el_message.find(
"nbins is <=0 - set to nbins = 1") != std::string::npos) ||
130 (el_message.find(
"nbinsy is <=0 - set to nbinsy = 1") != std::string::npos) ||
132 (el_location.find(
"CINTTypedefBuilder::Setup")!= std::string::npos) and
133 (el_message.find(
"possible entries are in use!") != std::string::npos))) {
149 if (die && (el_location !=
std::string(
"@SUB=TUnixSystem::DispatchSignals"))) {
150 std::ostringstream sstr;
151 sstr <<
"Fatal Root Error: " << el_location <<
"\n" << el_message <<
'\n';
154 except.clearMessage();
162 if (el_severity == SeverityLevel::kFatal) {
164 }
else if (el_severity == SeverityLevel::kSysError) {
171 edm::LogInfo(
"Root_Information") << el_location << el_message ;
175 void RootErrorHandler(
int level,
bool,
char const* location,
char const* message) {
176 RootErrorHandlerImpl(level, location, message);
180 void sig_dostack_then_abort(
int sig,siginfo_t*,
void*) {
182 const char* signalname =
"unknown";
185 signalname =
"bus error";
188 signalname =
"segmentation violation";
191 signalname =
"illegal instruction";
195 edm::LogError(
"FatalSystemSignal")<<
"A fatal system signal has occurred: "<<signalname;
196 std::cerr<<
"\n\nA fatal system signal has occurred: "<<signalname<<
"\n"
197 <<
"The following is the call stack containing the origin of the signal.\n"
198 <<
"NOTE:The first few functions on the stack are artifacts of processing the signal and can be ignored\n\n";
200 gSystem->StackTrace();
201 std::cerr<<
"\nA fatal system signal has occurred: "<<signalname<<
"\n";
206 void sig_abort(
int sig, siginfo_t*,
void*) {
216 unloadSigHandler_(pset.getUntrackedParameter<bool> (
"UnloadRootSigHandler")),
217 resetErrHandler_(pset.getUntrackedParameter<bool> (
"ResetRootErrHandler")),
218 loadAllDictionaries_(pset.getUntrackedParameter<bool>(
"LoadAllDictionaries")),
219 autoLibraryLoader_(loadAllDictionaries_
or pset.getUntrackedParameter<bool> (
"AutoLibraryLoader"))
224 gSystem->ResetSignal(kSigChild);
225 gSystem->ResetSignal(kSigBus);
226 gSystem->ResetSignal(kSigSegmentationViolation);
227 gSystem->ResetSignal(kSigIllegalInstruction);
228 gSystem->ResetSignal(kSigSystem);
229 gSystem->ResetSignal(kSigPipe);
230 gSystem->ResetSignal(kSigAlarm);
231 gSystem->ResetSignal(kSigUrgent);
232 gSystem->ResetSignal(kSigFloatingException);
233 gSystem->ResetSignal(kSigWindowChanged);
237 gSystem->ResetSignal(kSigBus);
238 gSystem->ResetSignal(kSigSegmentationViolation);
239 gSystem->ResetSignal(kSigIllegalInstruction);
257 SetErrorHandler(RootErrorHandler);
262 gInterpreter->SetClassAutoloading(1);
266 TTree::SetMaxTreeSize(kMaxLong64);
267 TH1::AddDirectory(kFALSE);
274 if (!
hasDictionary(
typeid(std::vector<std::vector<unsigned int> >))) {
286 TIter
iter(gROOT->GetListOfFiles());
287 TObject *
obj =
nullptr;
288 while(
nullptr != (obj =
iter.Next())) {
289 TFile*
f =
dynamic_cast<TFile*
>(
obj);
294 iter = TIter(gROOT->GetListOfFiles());
301 TThread::Initialize();
303 TObject::SetObjectStat(
false);
306 TVirtualStreamerInfo::Optimize(
false);
310 static thread_local TThread guard;
315 desc.
setComment(
"Centralized interface to ROOT.");
317 ->setComment(
"If True, signals are handled by this service, rather than by ROOT.");
319 ->setComment(
"If True, ROOT messages (e.g. errors, warnings) are handled by this service, rather than by ROOT.");
321 ->setComment(
"If True, enables automatic loading of data dictionaries.");
323 ->setComment(
"If True, loads all ROOT dictionaries.");
325 ->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.");
327 ->setComment(
"Sets ROOT's gDebug value.");
328 descriptions.
add(
"InitRootHandlers", desc);
333 s_ignoreWarnings =
false;
338 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)