From f50f383cc08488f136e4affd0ab4278d6493dc94 Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 3 Dec 2020 21:36:41 +0000 Subject: [PATCH] Reporting of std::bad_alloc in Subsystem::update Trying to trace down our bad-alloc exception, starting with the simplest place for now. --- simgear/structure/subsystem_mgr.cxx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/simgear/structure/subsystem_mgr.cxx b/simgear/structure/subsystem_mgr.cxx index a4ea8270..7497d7b1 100644 --- a/simgear/structure/subsystem_mgr.cxx +++ b/simgear/structure/subsystem_mgr.cxx @@ -30,9 +30,10 @@ #include "subsystem_mgr.hxx" #include "commands.hxx" -#include -#include #include "SGSmplstat.hxx" +#include +#include +#include const int SG_MAX_SUBSYSTEM_EXCEPTIONS = 4; const char SUBSYSTEM_NAME_SEPARATOR = '.'; @@ -828,8 +829,18 @@ SGSubsystemGroup::Member::update (double delta_time_sec) if (++exceptionCount > SG_MAX_SUBSYSTEM_EXCEPTIONS) { SG_LOG(SG_GENERAL, SG_ALERT, "(exceptionCount=" << exceptionCount << ", suspending)"); + simgear::reportError("suspending subsystem after too many errors:" + name); subsystem->suspend(); } + } catch (std::bad_alloc& ba) { + // attempting to track down source of these on Sentry.io + SG_LOG(SG_GENERAL, SG_ALERT, "caught bad_alloc processing subsystem:" << name); + simgear::reportError("caught bad_alloc processing subsystem:" + name); + + if (++exceptionCount > SG_MAX_SUBSYSTEM_EXCEPTIONS) { + SG_LOG(SG_GENERAL, SG_ALERT, "(exceptionCount=" << exceptionCount << ", suspending)"); + subsystem->suspend(); + } } }