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

Location missing if unhandled Exception occurred in async Main #166

Open
itn3000 opened this issue Feb 28, 2024 · 2 comments
Open

Location missing if unhandled Exception occurred in async Main #166

itn3000 opened this issue Feb 28, 2024 · 2 comments
Labels

Comments

@itn3000
Copy link
Contributor

itn3000 commented Feb 28, 2024

Overview

Cannot get location of unhandled exception occurred in async Main program.

Environment

  • netcoredbg version: 3.0.0-13 (27606c3, Release)
  • os: win10 x64
  • dotnet-sdk: 8.0.200
  • vscode: 1.86.2
  • C# extension: 2.18.16

Steps to reproduce

  1. create new console project
  2. open project with vscode
  3. write following code
  4. start vscode debugging session with following pipeTransport setting

code example

using System;
using System.Threading.Tasks;

class Program
{
    static void Abc()
    {
        throw new Exception();
    }
    static async Task Main()
    {
        await Task.Yield();
        Abc();
    }
}

pipeTransport setting

            "pipeTransport": {
                "pipeCwd": "${workspaceFolder}",
                "pipeProgram": "c:/Windows/System32/cmd.exe",
                "pipeArgs": ["/c"],
                "debuggerPath": "d:/bin/netcoredbg/netcoredbg.exe"
            }

Expected

program stops and display exception message.

Actual

program stopped but no message.
callstack information is "Unknown Source"

Additional Information

edit Main function to sync, it works as expected.

@gbalykov
Copy link
Member

Thanks for reporting, we'll take a look

@viewizard
Copy link
Member

Looks like async methods should care about exceptions in another way:

<- (E) {"body":{"allThreadsStopped":true,"reason":"exception","text":"An unhandled exception of type 'System.Exception' occurred in System.Private.CoreLib.dll","threadId":93289},"event":"stopped","seq":"14","type":"event"}

plus, in this case we have some "exception handler" (not user code)
Screenshot 2024-02-28 235650
in the same time, if I click on top frame, I see proper exception data:
Screenshot 2024-02-29 001547

For example, MS C# debugger:

<- (E) {"seq":28,"type":"event","event":"stopped","body":{"reason":"exception","threadId":93792,"text":"An exception of type 'System.Exception' occurred in vscode_test.dll but was not handled in user code","allThreadsStopped":true,"source":{"name":"Program.cs","path":"/home/viewizard/Desktop/projects_test/vscode_test/Program.cs"},"line":8,"column":9}}

Screenshot 2024-02-29 001147

@viewizard viewizard added the bug label Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants