It looks like the app just hangs but debugging it, this is really an exception being thrown on the GC thread. This exception is being thrown because the collection being iterated on got into a bad state and has entries that have been freed but are still in the list. This is the result of a missing lock during removal which happens when running the finalizer as that can race with adding to the list.
Description
Running WinUI Gallery published for AOT using latest WinAppSDK and CsWinRT preview will result in a hang randomly after navigating numerous pages.
Reproduction Steps
WindowsAppSDK: 1.6.240701003-experimental2 CsWinRT: 2.1.0-prerelease.240602.1 WindowsSdkPackageVersion: 10.0.22621.35-preview
Expected behavior
App doesn't hang
Actual behavior
It looks like the app just hangs but debugging it, this is really an exception being thrown on the GC thread. This exception is being thrown because the collection being iterated on got into a bad state and has entries that have been freed but are still in the list. This is the result of a missing lock during removal which happens when running the finalizer as that can race with adding to the list.
Regression?
No response
Known Workarounds
No response
Configuration
.NET 8 x64 AOT
Other information
No response