Skip to content

Crashes during debugging when pausing in VS2022/.NET9 #110552

@kg

Description

@kg

Description

Since upgrading to .NET 9, I get frequent debugger crashes when pausing in both Debug and Release configurations for my dictionary container. I haven't been able to notice any particular pattern to it.

Reproduction Steps

Run the 'Benchmarks' project from https://github.com/kg/SimdDictionary/ and hit Pause in VS during the self-test period while it is testing TailCollider, then make sure the Autos or Locals tab(s) are visible in the debugger. Local evaluation will fail and the application process will collapse if VectorizedDictionary code is currently running. Pausing in Main works though. This is not 100% reproducible - setting a breakpoint in a specific spot doesn't reproduce it every time - but if I run the self test and pause repeatedly it will eventually crash while evaluating locals. It seems to happen even if the autos/locals tabs aren't visible.

Image
Image

Expected behavior

No application crash even if local evaluation fails.

Actual behavior

Local evaluation fails and the application crashes.

---------------------------
Microsoft Visual Studio
---------------------------
The target process exited with code -1073740791 (0xC0000409) while evaluating the function ''.

If the problem happens regularly, consider disabling the Tools->Options setting "Debugging->General->Enable property evaluation and other implicit function calls" or debugging the cause by evaluating the expression from the Immediate window. See help for information on doing this.
---------------------------
OK   Help   
---------------------------

Regression?

I was able to get debugger crashes on .NET8 but it seems much much worse on 9. Could be a regression from upgrading VS, I'm not sure.

Known Workarounds

It looks like this could be related to some locals being NullRefs, so it's possible the workaround is to not use ref and Unsafe.NullRef at all, but that doesn't seem particularly reasonable.

Configuration

Visual Studio 2022 Version 17.12.3

PS C:\Users\kg> dotnet --list-runtimes
Microsoft.AspNetCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

x64 on a Ryzen 7950X

Other information

Sometimes it says evaluation failed for 'pair.Value' (but I don't have a watch on that, so what gives?)
Pair is defined like so:

[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct Pair {
    public K Key;
    public V Value;
}

Metadata

Metadata

Assignees

Labels

area-Diagnostics-coreclrin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions