From 7481749d58ff5e5cfc59baf48f9d82c2099abdc2 Mon Sep 17 00:00:00 2001 From: Lluis Sanchez Date: Wed, 31 Jul 2019 19:13:33 +0200 Subject: Fix stack overflow at startup The IdeApp.DispatchIdleActions method is sometimes called just after startup. When that happens, if the user has not had any interaction with the ide, the CommandService.LastUserInteration property will have the default DateTime value. The old code was substracting that value from the current time, which would be a huge amount of milliseconds, and would overflow when converting to int. It all would result with DispatchIdleActions being called over and over with a negative number, finally causing a stack overflow. Fixes VSTS #958148 --- main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'main') diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs index da8982d467..1776fbeb3b 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs @@ -541,9 +541,9 @@ namespace MonoDevelop.Ide // If the user interacted with the IDE just a moment ago, wait a bit more time before // running the action - var interactionSpan = (int)(DateTime.Now - commandService.LastUserInteraction).TotalMilliseconds; + var interactionSpan = Math.Max (0, (DateTime.Now - commandService.LastUserInteraction).TotalMilliseconds); if (interactionSpan < 500) { - DispatchIdleActions (500 - interactionSpan); + DispatchIdleActions (500 - (int) interactionSpan); return; } -- cgit v1.2.3