netcoredbg
netcoredbg copied to clipboard
Location missing if unhandled Exception occurred in async Main
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
- create new console project
- open project with vscode
- write following code
- 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.
Thanks for reporting, we'll take a look
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)
in the same time, if I click on top frame, I see proper exception data:
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}}