Skip to content

[NAOT] GC hang on IReferenceTrackerHost_DisconnectUnusedReferenceSources with the built-in DispatcherQueueSynchronizationContext #123321

@ahmed605

Description

@ahmed605

GC hangs when XAML calls ReferenceTrackerHost.IReferenceTrackerHost_DisconnectUnusedReferenceSources under Native AOT when the built-in Windows.System.DispatcherQueueSynchronizationContext is used.

The hang only happens under NAOT and not under CoreCLR JIT (even with NAOT emulation mode), it also seems to happen only when the built-in DispatcherQueueSynchronizationContext is used, I tried with a custom implementation based on this PR and with another implementation based on the same PR but uses CoreDispatcher rather than DispatcherQueue and both had no hangs.

TTD trace: https://1drv.ms/u/c/698e7f4810a15314/IQCt7gw4FC_ISYducKW8evBoAS7MZVCJsQ87y1GNB9ba0VM?e=rzMJMY
PDB (in case it's needed): https://1drv.ms/u/c/698e7f4810a15314/IQARY-TE2ZQPTb0Bf_WVubokAREiqnst1212Y4RfK-LWjwI?e=L4emh3

Main thread:

Image

Finalizer thread:

Image

Environment

SDK: .NET 10.0.102 SDK
OS: Windows 11 build 22631.5472
TFM: net10.0-windows10.0.26100.0
RID: win-x64
Windows SDK package version: 10.0.26100.81
CsWinRT version: 2.3.0-prerelease.251115.2
UseUwp: true

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-area-labelAn area label is needed to ensure this gets routed to the appropriate area owners

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions