Bug 33193 - Inspected values do not match actual values when the same variable name is used in a foreach loop
Summary: Inspected values do not match actual values when the same variable name is us...
Status: CONFIRMED
Alias: None
Product: Runtime
Classification: Mono
Component: Debugger (show other bugs)
Version: 5.2
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Zoltan Varga
URL:
Depends on:
Blocks:
 
Reported: 2015-08-18 09:45 UTC by Mike
Modified: 2017-05-31 21:51 UTC (History)
11 users (show)

See Also:
Tags: ac
Is this bug a regression?: ---
Last known good build:


Attachments
Example Project (302.06 KB, application/x-zip-compressed)
2015-08-18 09:45 UTC, Mike
Details
Screenshot - VS2015 (18.36 KB, image/png)
2015-08-18 17:34 UTC, Paul DiPietro [MSFT]
Details

Description Mike 2015-08-18 09:45:57 UTC
Created attachment 12549 [details]
Example Project

I've attached a sample project to reproduce the issue along with a screen shot depicting the issue.

Steps to reproduce:
1. Put a break point on line 30 of MainPage.xaml.cs
2. Mouse over "page.Title" to open the DataTip. The value shown is 3 but should be 1.
3. Mouse over "title" to open the DataTip. The value shown is 1.

The issue appears to manifest when the variable "page" is used in multiple loops.  It seems as though the debugger is displaying the last page from the previous loop.


Microsoft Visual Studio Professional 2013
Version 12.0.40629.00 Update 5
Microsoft .NET Framework
Version 4.5.51641

Installed Version: Professional

LightSwitch for Visual Studio 2013   06177-004-0444002-02664
Microsoft LightSwitch for Visual Studio 2013

Team Explorer for Visual Studio 2013   06177-004-0444002-02664
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013   06177-004-0444002-02664
Microsoft Visual Basic 2013

Visual C# 2013   06177-004-0444002-02664
Microsoft Visual C# 2013

Visual C++ 2013   06177-004-0444002-02664
Microsoft Visual C++ 2013

Visual F# 2013   06177-004-0444002-02664
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker   06177-004-0444002-02664
Microsoft® Visual Studio® 2013 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Windows Phone SDK 8.0 - ENU   06177-004-0444002-02664
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package   1.0
Application Insights Tools for Visual Studio

ASP.NET and Web Tools   12.5.60612.0
Microsoft Web Developer Tools contains the following components:
Support for creating and opening ASP.NET web projects
Browser Link: A communication channel between Visual Studio and browsers
Editor extensions for HTML, CSS, and JavaScript
Page Inspector: Inspection tool for ASP.NET web projects
Scaffolding: A framework for building and running code generators
Server Explorer extensions for Microsoft Azure Web Apps
Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Microsoft Azure

ASP.NET Web Frameworks and Tools 2012.2   4.1.21001.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.30612.0
For additional information, visit http://www.asp.net/

CodeMaid   #114
CodeMaid is an open source Visual Studio extension to cleanup, dig through and simplify our C#, C++, F#, VB, PHP, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.

Written by Steve Cadwallader, for more information visit http://www.codemaid.net/

Common Azure Tools   1.4
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Microsoft Advertising SDK for Windows Phone   
Microsoft Advertising SDK for Windows Phone
Build 

Microsoft Azure HDInsight HQL Service   1.0.0000.0
Language service for Hive query

Microsoft Azure HDInsight Tools for Visual Studio   1.0.0000.0
An integrated development environment for HDInsight application development.

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

Microsoft Azure Tools   2.5
Microsoft Azure Tools for Microsoft Visual Studio 2013 - v2.5.21104.1601

NuGet Package Manager   2.8.60723.765
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Office Developer Tools for Visual Studio 2013 ENU   12.0.30626
Microsoft Office Developer Tools for Visual Studio 2013 ENU

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   12.0.41025.0
Microsoft SQL Server Data Tools

StyleCop   4.7.49.0
Provides source code style and consistency tools. See http://www.stylecop.codeplex.com/ for more details.

Visual Studio Spell Checker   VSSpellChecker
An editor extension that checks the spelling of comments, strings, and plain text as you type.

VisualSVN   4.0.6
Integration with Subversion version control. For more information about VisualSVN, see the VisualSVN website at http://www.visualsvn.com
Copyright © 2005-2014 VisualSVN Ltd. All rights reserved.

Web Essentials 2013   2.5.3
Adds many useful features to Visual Studio for web developers.

Windows Phone 8.1 SDK Integration   1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.

Workflow Manager Tools 1.0   1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Xamarin   3.11.836.0 (ed5c750)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   5.1.5.3 (f98871a95a479f6d71b3067b7e5834d41fcb2118)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.Forms Intellisense   1.0
Provides intellisense for Xamarin.Forms in the XML editor.

Xamarin.iOS   8.10.4.0 (6db87c53c073f4af2f5247fb738a27ea08c094fd)
Visual Studio extension to enable development for Xamarin.iOS.

Xamarin.iOS Unified Migration   1.0
Automated migration for Xamarin iOS Classic projects to Unified

Xamarin.TestCloud.Integration   1.0
Early preview of Xamarin Test Cloud integration
Comment 1 Paul DiPietro [MSFT] 2015-08-18 17:33:32 UTC
I just attempted to reproduce the issue in VS2015 Professional and it does not appear as if the issue occurs using the project provided. Just as a matter of acknowledgement I'm going to set this to NEEDINFO for the moment so it can be investigated further as it may not be a Forms issue.


Microsoft Visual Studio Professional 2015
Version 14.0.23107.0 D14REL
Microsoft .NET Framework
Version 4.6.00079

Installed Version: Professional

Visual Basic 2015   00322-40000-00000-AA826
Microsoft Visual Basic 2015

Visual C# 2015   00322-40000-00000-AA826
Microsoft Visual C# 2015

Visual C++ 2015   00322-40000-00000-AA826
Microsoft Visual C++ 2015

Windows Phone SDK 8.0 - ENU   00322-40000-00000-AA826
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package   1.0
Application Insights Tools for Visual Studio

ASP.NET and Web Tools   14.0.20626.0
ASP.NET and Web Tools

ASP.NET Web Frameworks and Tools 2013   5.2.30624.0
For additional information, visit http://www.asp.net/

Common Azure Tools   1.5
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

GenerateUnitTest   1.0
Generates unit test code for methods in classes under test.

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

NuGet Package Manager   3.0.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   14.0.50616.0
Microsoft SQL Server Data Tools

Visual Studio Tools for Universal Windows Apps   14.0.23121.00 D14OOB
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

Xamarin   3.11.836.0 (ed5c750)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   5.1.5.3 (f98871a95a479f6d71b3067b7e5834d41fcb2118)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS   8.10.4.0 (6db87c53c073f4af2f5247fb738a27ea08c094fd)
Visual Studio extension to enable development for Xamarin.iOS.

Xamarin.iOS Unified Migration   1.0
Automated migration for Xamarin iOS Classic projects to Unified

Xamarin.TestCloud.Integration   1.0
Early preview of Xamarin Test Cloud integration
Comment 2 Paul DiPietro [MSFT] 2015-08-18 17:34:09 UTC
Created attachment 12562 [details]
Screenshot - VS2015
Comment 3 Mike 2015-08-18 18:05:01 UTC
Hey Paul, I noticed from the attachment you are showing the "title" variable has a value of 1 which is correct.  The issue I am seeing appears when mousing over "page.Title" which was showing 3 instead of 1.
Comment 4 Paul DiPietro [MSFT] 2015-08-18 19:39:46 UTC
I see what you mean; sorry for not taking that into account. What was odd was that I was running your project and it seemed to be showing null for those page.Title values, so I've no idea what's going on there. What I've just done though is put together roughly the same exact thing doing the double foreach in a Xamarin.Android app (thus not using Forms at all) and the same problem seems to occur as you described, so I'm pretty certain I can rule it out as a Forms issue, but it *does* in fact appear to be an issue of some sort.
Comment 5 Joaquin Jares 2017-05-26 17:52:51 UTC
I have a repro and a simple workaround. The runtime seems to be mixing the "page" declared in the other foreach (line 22) with the second one. If the first "page" is renamed, everything works. I'm working on a fix/redirecting to the correct team.
Comment 6 Joaquin Jares 2017-05-26 17:53:11 UTC
BTW, in the latest versions page is null in this case.
Comment 7 Joaquin Jares 2017-05-26 17:53:39 UTC
Also, this is also a repro in VSfMac. Redirecting to Runtime.
Comment 8 Zoltan Varga 2017-05-26 19:58:40 UTC
Does this also happen if the method is not async ?
Comment 10 Zoltan Varga 2017-05-30 18:58:18 UTC
We will probably need to add a debugger api to expose this information to the IDE.
Comment 11 David Karlaš 2017-05-31 02:26:18 UTC
I'm not 100%, but I think it can be added to GetScopes API: https://github.com/mono/mono/commit/7e3028c2c8164315251fd5f6b1eb82efdc6af7cc
Comment 12 Zoltan Varga 2017-05-31 21:51:44 UTC
https://github.com/mono/mono/pull/4961

Note You need to log in before you can comment on or make changes to this bug.