diff --git a/src/BloomExe/NonFatalProblem.cs b/src/BloomExe/NonFatalProblem.cs index 0079cf9248f9..4efdf2aa7c58 100644 --- a/src/BloomExe/NonFatalProblem.cs +++ b/src/BloomExe/NonFatalProblem.cs @@ -34,6 +34,11 @@ public enum PassiveIf /// public class NonFatalProblem { + // Guard against reentrant calls (e.g. ShowToast → SendBundle → ReportConnectionError → Report) + // which cause infinite mutual recursion leading to a StackOverflowException. + [ThreadStatic] + private static bool s_isReporting; + /// /// Always log, possibly inform the user, possibly throw the exception /// @@ -164,15 +169,24 @@ public static void Report( if ( !string.IsNullOrEmpty(shortUserLevelMessage) && Matches(passive).Any(s => channel.Contains(s)) + && !s_isReporting ) { - ShowToast( - shortUserLevelMessage, - exception, - fullDetailedMessage, - showSendReport, - showRequestDetails - ); + s_isReporting = true; + try + { + ShowToast( + shortUserLevelMessage, + exception, + fullDetailedMessage, + showSendReport, + showRequestDetails + ); + } + finally + { + s_isReporting = false; + } } } catch (Exception errorWhileReporting)