Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Internal error in the C# compiler" when try to evaluate statement in Watch\Immediate window #18273

Closed
dudikeleti opened this issue Mar 29, 2017 · 14 comments
Assignees
Labels
4 - In Review A fix for the issue is submitted for review. Area-Compilers Bug
Milestone

Comments

@dudikeleti
Copy link

dudikeleti commented Mar 29, 2017

Version Used:
Microsoft Visual Studio Enterprise 2017
Version 15.0.26228.9 D15RTWSVC
Microsoft .NET Framework
Version 4.6.01586

Project target framework:
.NETCoreApp 1.1
.NET Framework 4.5.2

Steps to Reproduce:

  1. Paste the following methods:
    class Program
    {
        static void M(out int x) { x = 10; }

        static void Main(string[] args)
        {
        }
    }
  1. Run the program and put a break point in the start of method "Main"

  2. When break point hit, paste the following statement in Watch window or in the Immediate window:

new Func<int>(delegate { int x; var y = new Func<int>(() => { M(out x); return 1; }).Invoke(); return y; }).Invoke() 

Expected Behavior:
"1" will printed

Actual Behavior:
"Internal error in the C# compiler" printed

StackTrace:
"The given key was not present in the dictionary."

>	mscorlib.dll!System.Collections.Generic.Dictionary<System.__Canon, System.__Canon>.this[System.__Canon].get(System.__Canon key)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.CodeGen.StackOptimizerPass1.RecordVarRead(Microsoft.CodeAnalysis.CSharp.Symbols.LocalSymbol local)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.CodeGen.StackOptimizerPass1.VisitLocal(Microsoft.CodeAnalysis.CSharp.BoundLocal node)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.BoundLocal.Accept(Microsoft.CodeAnalysis.CSharp.BoundTreeVisitor visitor)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.CodeGen.StackOptimizerPass1.VisitExpressionCore(Microsoft.CodeAnalysis.CSharp.BoundExpression node, Microsoft.CodeAnalysis.CSharp.CodeGen.ExprContext context)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.CodeGen.StackOptimizerPass1.VisitExpression(Microsoft.CodeAnalysis.CSharp.BoundExpression node, Microsoft.CodeAnalysis.CSharp.CodeGen.ExprContext context)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.CodeGen.StackOptimizerPass1.VisitAssignmentOperator(Microsoft.CodeAnalysis.CSharp.BoundAssignmentOperator node)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.BoundAssignmentOperator.Accept(Microsoft.CodeAnalysis.CSharp.BoundTreeVisitor visitor)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.CodeGen.StackOptimizerPass1.VisitExpressionCore(Microsoft.CodeAnalysis.CSharp.BoundExpression node, Microsoft.CodeAnalysis.CSharp.CodeGen.ExprContext context)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.CodeGen.StackOptimizerPass1.VisitExpressionCoreWithStackGuard(Microsoft.CodeAnalysis.CSharp.BoundExpression node, Microsoft.CodeAnalysis.CSharp.CodeGen.ExprContext context)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.CodeGen.StackOptimizerPass1.VisitExpression(Microsoft.CodeAnalysis.CSharp.BoundExpression node, Microsoft.CodeAnalysis.CSharp.CodeGen.ExprContext context)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.CodeGen.StackOptimizerPass1.VisitExpressionStatement(Microsoft.CodeAnalysis.CSharp.BoundExpressionStatement node)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.BoundExpressionStatement.Accept(Microsoft.CodeAnalysis.CSharp.BoundTreeVisitor visitor)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.CodeGen.StackOptimizerPass1.VisitStatement(Microsoft.CodeAnalysis.CSharp.BoundNode node)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.CodeGen.StackOptimizerPass1.Visit(Microsoft.CodeAnalysis.CSharp.BoundNode node)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.BoundTreeRewriter.DoVisitList<Microsoft.CodeAnalysis.CSharp.BoundStatement>(System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.CSharp.BoundStatement> list)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.BoundTreeRewriter.VisitBlock(Microsoft.CodeAnalysis.CSharp.BoundBlock node)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.CodeGen.StackOptimizerPass1.VisitBlock(Microsoft.CodeAnalysis.CSharp.BoundBlock node)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.BoundBlock.Accept(Microsoft.CodeAnalysis.CSharp.BoundTreeVisitor visitor)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.CodeGen.StackOptimizerPass1.VisitStatement(Microsoft.CodeAnalysis.CSharp.BoundNode node)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.CodeGen.StackOptimizerPass1.Visit(Microsoft.CodeAnalysis.CSharp.BoundNode node)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.CodeGen.StackOptimizerPass1.Analyze(Microsoft.CodeAnalysis.CSharp.BoundNode node, System.Collections.Generic.Dictionary<Microsoft.CodeAnalysis.CSharp.Symbols.LocalSymbol, Microsoft.CodeAnalysis.CSharp.CodeGen.LocalDefUseInfo> locals, bool debugFriendly)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.CodeGen.Optimizer.Optimize(Microsoft.CodeAnalysis.CSharp.BoundStatement src, bool debugFriendly, out System.Collections.Generic.HashSet<Microsoft.CodeAnalysis.CSharp.Symbols.LocalSymbol> stackLocals)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.CodeGenerator(Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol method, Microsoft.CodeAnalysis.CSharp.BoundStatement boundBody, Microsoft.CodeAnalysis.CodeGen.ILBuilder builder, Microsoft.CodeAnalysis.CSharp.Emit.PEModuleBuilder moduleBuilder, Microsoft.CodeAnalysis.DiagnosticBag diagnostics, Microsoft.CodeAnalysis.OptimizationLevel optimizations, bool emittingPdb)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.MethodCompiler.GenerateMethodBody(Microsoft.CodeAnalysis.CSharp.Emit.PEModuleBuilder moduleBuilder, Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol method, int methodOrdinal, Microsoft.CodeAnalysis.CSharp.BoundStatement block, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.CodeGen.LambdaDebugInfo> lambdaDebugInfo, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.CodeGen.ClosureDebugInfo> closureDebugInfo, Microsoft.CodeAnalysis.CSharp.StateMachineTypeSymbol stateMachineTypeOpt, Microsoft.CodeAnalysis.CodeGen.VariableSlotAllocator variableSlotAllocatorOpt, Microsoft.CodeAnalysis.DiagnosticBag diagnostics, Microsoft.CodeAnalysis.CodeGen.DebugDocumentProvider debugDocumentProvider, Microsoft.CodeAnalysis.CSharp.ImportChain importChainOpt, bool emittingPdb, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.CodeGen.SourceSpan> dynamicAnalysisSpans)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileSynthesizedMethods(Microsoft.CodeAnalysis.CSharp.TypeCompilationState compilationState)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileSynthesizedMethods(System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol> additionalTypes, Microsoft.CodeAnalysis.DiagnosticBag diagnostics)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileMethodBodies(Microsoft.CodeAnalysis.CSharp.CSharpCompilation compilation, Microsoft.CodeAnalysis.CSharp.Emit.PEModuleBuilder moduleBeingBuiltOpt, bool generateDebugInfo, bool hasDeclarationErrors, Microsoft.CodeAnalysis.DiagnosticBag diagnostics, System.Predicate<Microsoft.CodeAnalysis.CSharp.Symbol> filterOpt, System.Threading.CancellationToken cancellationToken)	Unknown
 	Microsoft.CodeAnalysis.CSharp.dll!Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CompileMethods(Microsoft.CodeAnalysis.Emit.CommonPEModuleBuilder moduleBuilder, bool emittingPdb, Microsoft.CodeAnalysis.DiagnosticBag diagnostics, System.Predicate<Microsoft.CodeAnalysis.ISymbol> filterOpt, System.Threading.CancellationToken cancellationToken)	Unknown
 	Microsoft.CodeAnalysis.dll!Microsoft.CodeAnalysis.Compilation.Compile(Microsoft.CodeAnalysis.Emit.CommonPEModuleBuilder moduleBuilder, bool emittingPdb, Microsoft.CodeAnalysis.DiagnosticBag diagnostics, System.Predicate<Microsoft.CodeAnalysis.ISymbol> filterOpt, System.Threading.CancellationToken cancellationToken)	Unknown
 	Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.ExpressionCompiler.dll!Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.CompilationContext.CompileExpression(string typeName, string methodName, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ExpressionEvaluator.Alias> aliases, Microsoft.CodeAnalysis.CodeGen.CompilationTestData testData, Microsoft.CodeAnalysis.DiagnosticBag diagnostics, out Microsoft.CodeAnalysis.ExpressionEvaluator.ResultProperties resultProperties)	Unknown
 	Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.ExpressionCompiler.dll!Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.EvaluationContext.CompileExpression(string expr, Microsoft.VisualStudio.Debugger.Evaluation.DkmEvaluationFlags compilationFlags, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ExpressionEvaluator.Alias> aliases, Microsoft.CodeAnalysis.DiagnosticBag diagnostics, out Microsoft.CodeAnalysis.ExpressionEvaluator.ResultProperties resultProperties, Microsoft.CodeAnalysis.CodeGen.CompilationTestData testData)	Unknown
 	Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.dll!Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.Microsoft.VisualStudio.Debugger.ComponentInterfaces.IDkmClrExpressionCompiler.CompileExpression.AnonymousMethod__1(Microsoft.CodeAnalysis.ExpressionEvaluator.EvaluationContextBase context, Microsoft.CodeAnalysis.DiagnosticBag diagnostics)	Unknown
 	Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.dll!Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileWithRetry<Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileExpressionResult>(System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ExpressionEvaluator.MetadataBlock> metadataBlocks, Microsoft.CodeAnalysis.DiagnosticFormatter formatter, Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CreateContextDelegate createContext, Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileDelegate<Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileExpressionResult> compile, Microsoft.CodeAnalysis.ExpressionEvaluator.DkmUtilities.GetMetadataBytesPtrFunction getMetaDataBytesPtr, out string errorMessage)	Unknown
 	Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.dll!Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileWithRetry<Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileExpressionResult>(Microsoft.VisualStudio.Debugger.Clr.DkmClrModuleInstance moduleInstance, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ExpressionEvaluator.MetadataBlock> metadataBlocks, Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CreateContextDelegate createContext, Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileDelegate<Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileExpressionResult> compile, out string errorMessage)	Unknown
 	Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.dll!Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.Microsoft.VisualStudio.Debugger.ComponentInterfaces.IDkmClrExpressionCompiler.CompileExpression(Microsoft.VisualStudio.Debugger.Evaluation.DkmLanguageExpression expression, Microsoft.VisualStudio.Debugger.Clr.DkmClrInstructionAddress instructionAddress, Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext inspectionContext, out string error, out Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmCompiledClrInspectionQuery result)	Unknown
 	Microsoft.VisualStudio.Debugger.Engine.dll!Microsoft.VisualStudio.Debugger.EntryPoint.IDkmClrExpressionCompiler_CompileExpression(System.IntPtr pvClassInfo, System.IntPtr Expression, System.IntPtr InstructionAddress, System.IntPtr InspectionContext, ref System.IntPtr Error, ref System.IntPtr Result)	Unknown
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	Microsoft.VisualStudio.Debugger.Engine.dll!Microsoft.VisualStudio.Debugger.Evaluation.DkmLanguageExpression.CompileExpression(Microsoft.VisualStudio.Debugger.Clr.DkmClrInstructionAddress InstructionAddress, Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext InspectionContext, out string Error, out Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmCompiledClrInspectionQuery Result)	Unknown
 	vsdebugeng.manimpl.dll!VSDebugEngine.ManagedEE.EntryPoint.Microsoft.VisualStudio.Debugger.ComponentInterfaces.IDkmLanguageExpressionEvaluator.EvaluateExpression(Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext inspectionContext, Microsoft.VisualStudio.Debugger.DkmWorkList workList, Microsoft.VisualStudio.Debugger.Evaluation.DkmLanguageExpression expression, Microsoft.VisualStudio.Debugger.CallStack.DkmStackWalkFrame stackFrame, Microsoft.VisualStudio.Debugger.DkmCompletionRoutine<Microsoft.VisualStudio.Debugger.Evaluation.DkmEvaluateExpressionAsyncResult> completionRoutine)	Unknown
 	Microsoft.VisualStudio.Debugger.Engine.dll!Microsoft.VisualStudio.Debugger.EntryPoint.IDkmLanguageExpressionEvaluator_EvaluateExpression(System.IntPtr pvClassInfo, System.IntPtr InspectionContext, System.IntPtr WorkList, System.IntPtr Expression, System.IntPtr StackFrame, System.IntPtr CompletionRoutine)	Unknown
@brettfo
Copy link
Member

brettfo commented Apr 11, 2017

FYI, I've also hit a similar issue but a different call stack when debugging a .NET Core app with embedded PDBs:

Exception:

System.NotImplementedException occurred
  HResult=0x80004001
  Message=The method or operation is not implemented.
  Source=Microsoft.VisualStudio.Debugger.Engine
  StackTrace:
   at XapiExceptionProcessing.ThrowHR(Int32 code) in F:\dd\src\debugger\concord\Dispatcher\Managed\ExceptionProcessing.cs:line 392

Stack trace:

 	Microsoft.VisualStudio.Debugger.Engine.dll!XapiExceptionProcessing.ThrowHR(int code) Line 392	C#
 	Microsoft.VisualStudio.Debugger.Engine.dll!Microsoft.VisualStudio.Debugger.Clr.DkmClrModuleInstance.GetSymUnmanagedReader() Line 133792	C#
>	Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.dll!Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CreateMethodContext(Microsoft.VisualStudio.Debugger.Clr.DkmClrInstructionAddress instructionAddress, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ExpressionEvaluator.MetadataBlock> metadataBlocks, bool useReferencedModulesOnly) Line 290	C#
 	Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.dll!Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.Microsoft.VisualStudio.Debugger.ComponentInterfaces.IDkmClrExpressionCompiler.CompileExpression.AnonymousMethod__0(System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ExpressionEvaluator.MetadataBlock> blocks, bool useReferencedModulesOnly) Line 109	C#
 	Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.dll!Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileWithRetry<Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileExpressionResult>(System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ExpressionEvaluator.MetadataBlock> metadataBlocks, Microsoft.CodeAnalysis.DiagnosticFormatter formatter, Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CreateContextDelegate createContext, Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileDelegate<Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileExpressionResult> compile, Microsoft.CodeAnalysis.ExpressionEvaluator.DkmUtilities.GetMetadataBytesPtrFunction getMetaDataBytesPtr, out string errorMessage) Line 339	C#
 	Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.dll!Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileWithRetry<Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileExpressionResult>(Microsoft.VisualStudio.Debugger.Clr.DkmClrModuleInstance moduleInstance, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ExpressionEvaluator.MetadataBlock> metadataBlocks, Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CreateContextDelegate createContext, Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileDelegate<Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.CompileExpressionResult> compile, out string errorMessage) Line 313	C#
 	Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.dll!Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler.Microsoft.VisualStudio.Debugger.ComponentInterfaces.IDkmClrExpressionCompiler.CompileExpression(Microsoft.VisualStudio.Debugger.Evaluation.DkmLanguageExpression expression, Microsoft.VisualStudio.Debugger.Clr.DkmClrInstructionAddress instructionAddress, Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext inspectionContext, out string error, out Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmCompiledClrInspectionQuery result) Line 123	C#
 	Microsoft.VisualStudio.Debugger.Engine.dll!Microsoft.VisualStudio.Debugger.EntryPoint.IDkmClrExpressionCompiler_CompileExpression(System.IntPtr pvClassInfo, System.IntPtr Expression, System.IntPtr InstructionAddress, System.IntPtr InspectionContext, ref System.IntPtr Error, ref System.IntPtr Result) Line 184724	C#
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	Microsoft.VisualStudio.Debugger.Engine.dll!Microsoft.VisualStudio.Debugger.Evaluation.DkmLanguageExpression.CompileExpression(Microsoft.VisualStudio.Debugger.Clr.DkmClrInstructionAddress InstructionAddress, Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext InspectionContext, out string Error, out Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmCompiledClrInspectionQuery Result) Line 49878	C#
 	vsdebugeng.manimpl.dll!VSDebugEngine.ManagedEE.EntryPoint.Microsoft.VisualStudio.Debugger.ComponentInterfaces.IDkmLanguageExpressionEvaluator.EvaluateExpression(Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext inspectionContext, Microsoft.VisualStudio.Debugger.DkmWorkList workList, Microsoft.VisualStudio.Debugger.Evaluation.DkmLanguageExpression expression, Microsoft.VisualStudio.Debugger.CallStack.DkmStackWalkFrame stackFrame, Microsoft.VisualStudio.Debugger.DkmCompletionRoutine<Microsoft.VisualStudio.Debugger.Evaluation.DkmEvaluateExpressionAsyncResult> completionRoutine) Line 184	C#
 	Microsoft.VisualStudio.Debugger.Engine.dll!Microsoft.VisualStudio.Debugger.EntryPoint.IDkmLanguageExpressionEvaluator_EvaluateExpression(System.IntPtr pvClassInfo, System.IntPtr InspectionContext, System.IntPtr WorkList, System.IntPtr Expression, System.IntPtr StackFrame, System.IntPtr CompletionRoutine) Line 174029	C#

@RussKie
Copy link
Member

RussKie commented Apr 27, 2017

Same here debugging WinForms project
screen shot 2017-04-27 at 10 45 58 pm

Windows 10 v1703
Microsoft Visual Studio Enterprise 2017
Version 15.0.26228.4 D15RTWSVC
Microsoft .NET Framework
Version 4.7.02046

@tmat
Copy link
Member

tmat commented Apr 27, 2017

@brettfo That seems unrelated. Could you please file a separate bug?

@tmat tmat added this to the 15.3 milestone Apr 27, 2017
@RussKie
Copy link
Member

RussKie commented Apr 28, 2017

It seems my error stemmed from the fact I was debugging a project on Mac under Parallels desktop and the project wasn't located on the windows' C:\ drive.
This link helped to resolve the issue http://stackoverflow.com/questions/43309509/visual-studio-2017-project-cant-run-debug-in-parallels-desktop-on-mac/43313815

Still the error could be much clearer.

@tmat
Copy link
Member

tmat commented Apr 28, 2017

@brettfo Do you have a repro or a crash dump?

@tmat
Copy link
Member

tmat commented Apr 28, 2017

Repro unit test:

        [Fact, WorkItem(18273, "https://github.com/dotnet/roslyn/issues/18273")]
        public void CapturedLocalInNestedLambda()
        {
            var source = @"
using System;

class C
{
    void M() { }
}";
            var compilation0 = CreateStandardCompilation(source, options: TestOptions.DebugDll);
            WithRuntimeInstance(compilation0, runtime =>
            {
                var context = CreateMethodContext(runtime, "C.M");

                var testData = new CompilationTestData();
                context.CompileExpression("new Action(() => { int x; new Func<int>(() => x).Invoke(); }).Invoke()", out var error, testData);
                Assert.Null(error);
                testData.GetMethodData("<>x.<>m0").VerifyIL("");
            });
        }

@tmat
Copy link
Member

tmat commented Apr 28, 2017

@cston Could you take a look? The variable x is not being defined in the bound block (it's captured) but the optimizer is looking for it for some reason.

@jaredpar
Copy link
Member

jaredpar commented May 4, 2017

@RussKie
Copy link
Member

RussKie commented May 7, 2017

@jaredpar I don't have access to your link :(

I am consistently having the problem debugging https://github.com/gitextensions/gitextensions project - both on my Windows PC and running under Parallels on Mac. Both VS2015 and VS2017.

Is there a way to find more information on what fails/why the error occurs?

@jaredpar
Copy link
Member

jaredpar commented May 8, 2017

@RussKie

Unfortunately that link can't be accessed except by MSFT employees. It represents a Watson crash of the bug. I added it here so we can track both issues together.

Don't have more details yet as we are still digging into this.

@cston
Copy link
Member

cston commented May 8, 2017

@RussKie This error occurs when the expression being evaluated contains nested lambdas where the inner lambda closes over a local declared in the outer lambda.

@tudor-turcu
Copy link

Unfortunately the issue still wasn't fixed in VS 2022
image

@nathanpovo
Copy link

Possibly related to #19257

@cston
Copy link
Member

cston commented Feb 8, 2023

@tudor-turcu, thanks for reporting an additional failure. The original bug should be fixed, so you may be hitting a distinct issue. Please consider opening a new issue with a simple example that hits the error. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 - In Review A fix for the issue is submitted for review. Area-Compilers Bug
Projects
None yet
Development

No branches or pull requests

10 participants