question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Method with a function pointer local breaks variables view and debug console

See original GitHub issue

Issue Description

When the debugger is stopped in a method that contains a local typed as a function pointer, all state related debug LSP requests seem to break.

Steps to Reproduce

  1. Download repro project (MethodPointerDebugRepro.zip or do dotnet new console and paste the code below)
  2. Set breakpoint on Program.cs:L10
  3. Launch debug
Program.cs
using System;

namespace MethodPointerDebugRepro
{
    internal static class Program
    {
        private static unsafe void Main(string[] args)
        {
            // Set breakpoint here.
            delegate*<void> messageWriter = &WriteMessage;
            messageWriter();
        }

        private static void WriteMessage()
        {
            Console.WriteLine("testing");
        }
    }
}
MethodPointerDebugRepro.csproj
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
  </PropertyGroup>

</Project>

Expected Behavior

Variables view shows locals and does not display an error. Debug console works.

Actual Behavior

Variables view shows error Error processing 'variables' request. Unknown Error: 0x80135100. Evaluating anything in the debug repl returns Internal error in the C# compiler.

image

Logs

OmniSharp log

Starting OmniSharp server at 9/10/2020, 8:25:57 AM
    Target: c:\MethodPointerDebugRepro

OmniSharp server started.
    Path: c:\Users\seeminglyscience\.vscode\extensions\ms-dotnettools.csharp-1.23.2\.omnisharp\1.37.1\OmniSharp.exe
    PID: 26668

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 16.8.0 - "c:\Users\seeminglyscience\.vscode\extensions\ms-dotnettools.csharp-1.23.2\.omnisharp\1.37.1\.msbuild\Current\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to 'c:\Users\seeminglyscience\.vscode\extensions\ms-dotnettools.csharp-1.23.2\.omnisharp\1.37.1\.msbuild\Current\Bin\MSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 16.8.0 - "c:\Users\seeminglyscience\.vscode\extensions\ms-dotnettools.csharp-1.23.2\.omnisharp\1.37.1\.msbuild\Current\Bin"
            CscToolExe = csc.exe
            CscToolPath = c:\Users\seeminglyscience\.vscode\extensions\ms-dotnettools.csharp-1.23.2\.omnisharp\1.37.1\.msbuild\Current\Bin\Roslyn
            MSBuildExtensionsPath = c:\Users\seeminglyscience\.vscode\extensions\ms-dotnettools.csharp-1.23.2\.omnisharp\1.37.1\.msbuild
            MSBuildToolsPath = c:\Users\seeminglyscience\.vscode\extensions\ms-dotnettools.csharp-1.23.2\.omnisharp\1.37.1\.msbuild\Current\Bin
[info]: OmniSharp.WorkspaceInitializer
        Project system 'OmniSharp.Cake.CakeProjectSystem' is disabled in the configuration.
[info]: OmniSharp.MSBuild.ProjectSystem
        No solution files found in 'c:\MethodPointerDebugRepro'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\MethodPointerDebugRepro\MethodPointerDebugRepro.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'c:\MethodPointerDebugRepro'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\MethodPointerDebugRepro\MethodPointerDebugRepro.csproj
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location 'c:\MethodPointerDebugRepro' on host 2524.
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file 'c:\MethodPointerDebugRepro\MethodPointerDebugRepro.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'c:\MethodPointerDebugRepro\MethodPointerDebugRepro.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: MethodPointerDebugRepro
[info]: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers
        Solution initialized -> queue all documents for code analysis. Initial document count: 3.

C# log

(empty)

Environment information

VSCode version: 1.48.2 C# Extension: 1.23.2

Dotnet Information .NET SDK (reflecting any global.json): Version: 5.0.100-rc.2.20459.10 Commit: 2815f3cae1

Runtime Environment: OS Name: Windows OS Version: 10.0.18362 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\5.0.100-rc.2.20459.10\

Host (useful for support): Version: 5.0.0-rc.2.20458.14 Commit: 482494f9ec

.NET SDKs installed: 1.0.4 [C:\Program Files\dotnet\sdk] 3.0.100 [C:\Program Files\dotnet\sdk] 3.1.100 [C:\Program Files\dotnet\sdk] 3.1.102 [C:\Program Files\dotnet\sdk] 3.1.300 [C:\Program Files\dotnet\sdk] 5.0.100-rc.2.20459.10 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.All 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.0-rc.2.20458.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.0-alpha.1.19564.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.0-rc.2.20458.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.0-rc.2.20454.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download

Visual Studio Code Extensions
Extension Author Version
Align steve8708 0.2.0
better-powershell-syntax-highlighting justin-grote 0.0.2
bracket-pair-colorizer-2 CoenraadS 0.2.0
csharp ms-dotnettools 1.23.2
docomment k–kato 0.1.18
EditorConfig EditorConfig 0.15.1
github-markdown-preview bierner 0.0.2
gitlens eamodio 10.2.2
keyboard-quickfix pascalsenn 0.0.5
language-x86-64-assembly 13xforever 2.3.0
markdown-all-in-one yzhang 3.3.0
markdown-checkbox bierner 0.1.3
markdown-emoji bierner 0.0.9
markdown-preview-github-styles bierner 0.1.6
markdown-yaml-preamble bierner 0.0.4
midl-webidl-syntax dave-deletethis 0.0.1
msbuild-project-tools tintoy 0.3.8
pascal alefragnani 9.1.0
pascal-formatter alefragnani 2.4.0
powershell ms-vscode 2020.6.0
project-manager alefragnani 11.3.0
reg ionutvmi 1.0.1
roslynator josefpihrt-vscode 3.0.0
terminal-input SeeminglyScience 1.0.0
vim vscodevim 1.16.0
vscode-antlr4 mike-lischke 2.2.4
vscode-cil-complete wk-j 0.0.5
vscode-custom-snippets NgekNgok 1.1.4
vscode-markdownlint DavidAnson 0.36.3
vscode-pull-request-github GitHub 0.19.0
vscode-xml redhat 0.13.0
vscode-yaml redhat 0.10.1
xml DotJoshJohnson 2.5.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
gregg-miskellycommented, Sep 10, 2020

I have a fix. Should go in shortly.

0reactions
gregg-miskellycommented, Oct 24, 2022

I would probably open two issues, but either way is fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

7 Ways to Look at the Values of Variables While Debugging in ...
In order to look at the value of variables while you are debugging, you first need to be in break mode. You can...
Read more >
Stepping through code and inspecting variables to isolate bugs
You can precisely control execution of your code from a breakpoint, stepping into and out of called functions as necessary to determine where...
Read more >
How to debug whether a pointer argument was modified by a ...
I want to check the difference in these pointer arguments before and after the function call. Is this watch possible? Note that these...
Read more >
JavaScript debugging reference - Chrome Developers
# Restart a function (frame) in a call stack · Pause function execution at a breakpoint. The Call Stack pane records the order...
Read more >
Function Pointer Issues - Emscripten
The workaround is to pass the structure by reference, or simply not mix C and C++ in that location (for example, rename the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found