Skip to content

Exception thrown in GC callback while walking native object wrappers on AOT #104582

@manodasanW

Description

@manodasanW

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

  • Build and run AOT compatible version of WinUI gallery with the below versions updated in standalone.props.
  • Navigate through the different pages and eventually it will hang

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

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

Status

No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions