Skip to content

Deadlock in loader lock (CoreCLR) from background GC in XAML apps #114182

Closed

Description

@Sergio0694

Description

We're hitting random hangs in the Microsoft Store in debug builds on CoreCLR.

Context from @hoyosjs:

"This is a loader lock deadlock
[...]

  • Thread 3 tries to do a GC from the added pressure, which tries to start the background GC thread.
  • BG thread (and a ton of others) fail to start - they are stuck in LdrpInitializeThread on LdrpAcquireLoaderLock
  • They can't start bc thread 16 has the lock (LdrShutdownThread) and it's doing TLS destruction. Part of it must happen in COOP GC. Transitioning to coop means it waits for the original GC...

Crash dump (MSFT only): loader_hang_dmp.zip

Reproduction Steps

It just happens when using the app for a while.

Configuration

  • .NET 9.0.202

Activity

  1. added
    partner-impactThis issue impacts a partner who needs to be kept updated
    on Apr 2, 2025
  2. added theissue type on Apr 2, 2025
  3. jkotas commented on Apr 3, 2025

    @jkotas
    Member

    Duplicate of #110350 . cc @VSadov

  4. added
    needs-author-actionAn issue or pull request that requires more info or actions from the author.
    on Apr 3, 2025
  5. jkotas commented on Apr 3, 2025

    @jkotas
    Member

    @Sergio0694 Could you please validate that it is fixed in 9.0.5?

    (backport PR #113055)

  6. Sergio0694 commented on Apr 3, 2025

    @Sergio0694
    ContributorAuthor

    Oh that's nice! I can try, yes, though it might be slightly tricky as I can't repro this myself.
    Just to confirm, is this only affecting CoreCLR, or does this affect Native AOT as well?

  7. VSadov commented on Apr 3, 2025

    @VSadov
    Member

    Yes, this looks like #110350 . The fix has been backported to 9.0, but may not be available till the next servicing release.
    As Jan suggested - it would be very helpful if you could try with 9.0.5 bits (i.e. #113055)

  8. jkotas commented on Apr 3, 2025

    @jkotas
    Member

    Just to confirm, is this only affecting CoreCLR, or does this affect Native AOT as well?

    It does not affect Native AOT. The fix was to switch regular CoreCLR to how Native AOT works.

  9. Sergio0694 commented on Apr 3, 2025

    @Sergio0694
    ContributorAuthor

    Perfect, thank you for confirming! At least we know this only affects our dev inner loop then 🙂

  10. removed
    untriagedNew issue has not been triaged by the area owner
    on Apr 3, 2025
  11. added this to the 10.0.0 milestone on Apr 3, 2025
  12. VSadov commented on Apr 3, 2025

    @VSadov
    Member

    NativeAOT had a remotely related issue, fixed in #113194

    But that is related to COM and is pretty hard to observe, even intentionally.
    It would not show up as a deadlock though. In fact, in most cases it would not have any adverse effects, so is unlikely to bother you.

  13. added
    needs-author-actionAn issue or pull request that requires more info or actions from the author.
    on Apr 7, 2025
  14. Sergio0694 commented on Apr 7, 2025

    @Sergio0694
    ContributorAuthor

    I assume I can test the fix by installing the latest nightly SDK from the 9.0 branch from the SDK repo?

  15. added
    needs-further-triageIssue has been initially triaged, but needs deeper consideration or reconsideration
    and removed
    needs-author-actionAn issue or pull request that requires more info or actions from the author.
    on Apr 7, 2025
  16. jkotas commented on Apr 7, 2025

    @jkotas
    Member

    Yes, you can do that if you do not want to wait for official release.

  17. added
    needs-author-actionAn issue or pull request that requires more info or actions from the author.
    and removed
    needs-further-triageIssue has been initially triaged, but needs deeper consideration or reconsideration
    on Apr 7, 2025
  18. dotnet-policy-service commented on Apr 7, 2025

    @dotnet-policy-service
    Contributor

    This issue has been marked needs-author-action and may be missing some important information.

  19. dotnet-policy-service commented on Apr 22, 2025

    @dotnet-policy-service
    Contributor

    This issue has been automatically marked no-recent-activity because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will remove no-recent-activity.

  20. dotnet-policy-service commented on May 6, 2025

    @dotnet-policy-service
    Contributor

    This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.

  21. removed this from the 10.0.0 milestone on May 6, 2025
  22. locked and limited conversation to collaborators on Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-GC-coreclrneeds-author-actionAn issue or pull request that requires more info or actions from the author.partner-impactThis issue impacts a partner who needs to be kept updated

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions