Skip to content

[Backport] Fix synchronous cancellation race in Channels (PR #132230) to .NET 10 #136501

Open

Description

@Skyuzii

Description

This issue is a request to backport the critical fix from PR #132230 to the .NET 10 servicing branch (release/10.0-staging). A backport PR (#135891) has already been created and is currently awaiting review.

Original PR

Problem

A race condition exists in System.Threading.Channels when cancellation occurs synchronously during the registration of a cancellation token. In this scenario, the operation could complete without properly reserving its slot, leading to a double-completion. This corruption of the internal waiter/reader linked lists can cause assertion failures in RendezvousChannel and silently lose items during a direct handoff in BoundedChannel.

Customer Impact

This is a critical reliability issue. Applications using System.Threading.Channels for producer/consumer patterns (a common scenario in high-throughput or asynchronous processing) can experience silent data loss or unexpected crashes (assertion failures) under specific timing conditions involving cancellation. This makes the fix essential for production stability.

Existing Backport PR

A backport PR has already been created:

This PR is ready for review and includes the necessary changes for the .NET 10 branch. We kindly request that the area owners or the engineering lead responsible for System.Threading.Channels review it, as it addresses a critical reliability issue.

Request

Please consider reviewing and approving PR #135891 for inclusion in an upcoming .NET 10 servicing release. The fix is well-contained and includes deterministic regression tests for both bounded and rendezvous channels.

Testing / Validation

The original PR includes validation details:

  • 1,599 System.Threading.Channels debug tests passed.
  • Debug and Release library builds succeeded with no warnings.
  • A 3,000,000-item repro in Release mode completed without missing items.

Risk

Low. The change is surgical, replacing a race-prone check with an immutable _isCancelable field initialized before the callback can run. It preserves the existing fast path and pooling behavior. The PR has been thoroughly tested and reviewed.

Workaround

None. The issue is a race condition that cannot be reliably mitigated at the application level.

Activity

  1. added
    untriaged
    on Oct 27, 2026
  2. dotnet-policy-service commented on Oct 27, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @JulieLeeMSFT, @VSadov
    See info in area-owners.md if you want to be subscribed.

  3. Skyuzii commented on Oct 28, 2026

    @Skyuzii
    Author

    Friendly ping @PranavSenthilnathan @steveisok @JulieLeeMSFT @jeffhandley

    Could someone please take a look at this issue? The backport PR #135891 is already open and ready for review. It fixes a critical race condition that can cause silent data loss and even process crashes on .NET 10. Thanks!

  4. Skyuzii commented on Nov 3, 2026

    @Skyuzii
    Author

    @PranavSenthilnathan @steveisok @JulieLeeMSFT @jeffhandley
    Could someone please take a look at this issue?

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-System.Threadinguntriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions