Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2015 Debugger Corruption - Is it a bug or just me?

Have I gone mad? I've always been able to trust the debugger right?

Turns out that during a debugging session with VS2015, when I for example change the value of a variable in the Immediate Window, then that assignment results in a "garbage" value being assigned. It's the same garbage value every time, but completely wrong nonetheless.

I've distilled this down to the simplest console application repro, and just in case you might think to concur with my self-assessment of madness, I've also made a screenshot video clip of it going awry.

Are you guys getting this issue too or is this a local machine issue?

Here are the one drive links for:

  • Video Clip of repro
  • Source code for repro (very small - main class code below)

PS: I'm running Windows 10 Enterprise x64, VS2015 Enterprise with all current updates for OS and VS applied. The underlying hardware is modern hardware that I've had no issue with under VS2013.

internal class Program
{
    private static DateTime? _nullableDateTime;

    private static void Main( string[] args )
    {
        // Use the debugger to step through this repro. 
        // * Not sure if it matters, but I started with F11 right from the         start without any breakpoints.
        // ==============================================================================================

        // 1. Variable starts off with default of null
        //    The following statement will confirm that with an "empty" value in the console window
        Console.WriteLine( _nullableDateTime );

        // 2. The next statement assigns the current date and time
        _nullableDateTime = DateTime.Now;

        // 3. The following statement will confirm the correct value in the console window
        Console.WriteLine( _nullableDateTime );

        // 4. THIS IS WHERE THE TROUBLE STARTS
        //    Now, using the immediate window, change the value of the variable with the 
        //    following statement (after the colon) : _nullableDateTime = DateTime.Now
        //    
        //  
        //

        // 5. After changing the value via the immediate window, let's look at it's value now.
        //    For me (as can be seen in the video), I get the completely wrong value in the console window.
        Console.WriteLine( _nullableDateTime );
    }
}

I'll start to put together the same for a VS Connect issue.

EDIT: I'm beginning to wonder whether this is an issue just for me as no-one has confirmed that this is happening for them too.

EDIT: The connect issue has been filed here.

like image 807
Jaans Avatar asked Aug 09 '15 06:08

Jaans


2 Answers

I can confirm something similar happens in my install of Visual Studio 2015 I also ran the same code in Visual Studio 2013 (which luckily I did not uninstall when I upgraded) and it does not happen there:

v2013 vs 2015

So yes it does seem as if you've just uncovered a bug in Visual Studio 2015 (my machine is running Windows 7 Pro so this is not a Windows 10 issue). Unfortunately I lack the professional knowledge to comment on your mental well being so make no assumptions on that regard :-)

like image 60
Eli Algranti Avatar answered Oct 23 '22 05:10

Eli Algranti


Similar problem here. Just take a Class and target .NET 3.5

public class DoSomething
{
    public void Makeit()
    {
    //  Set Breakpoint here
        SortedList<string, string> sortedList = new SortedList<string, string>();
        sortedList.Add("test", "1");
        sortedList.Add("test2", "2"); 
        //when breakpoint hits, uncomment the next line and press F5
        //sortedList.Add("test4", "5");
//Exception


class Program
{
    static void Main(string[] args)
    {
        TestLibrary.DoSomething bla = new TestLibrary.DoSomething();

        bla.Makeit();
    }
}

[animated explanation]

like image 30
Deniz Düleç Avatar answered Oct 23 '22 03:10

Deniz Düleç