fix: a built-in channel's wait, cancelled by its token, completes on the real thread pool
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 43/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- csharp
調査の方向性
Start with SimulationTaskCompletionRace and the built-in channel cancellation callbacks described in the issue; inspect how UnboundedChannel<T> and the bounded channel complete pending waits. Then compare the controlled cancellation race with Task.WaitAsync and check the ChannelConformanceTests scenarios named in the issue. Done means cancelled waits complete through controlled operations and channel state still matches the BCL behavior.
索引モデルが issue の本文から書いたものです。
説明
Problem
A built-in channel completes a pending wait (ReadAsync, WaitToReadAsync, WriteAsync, WaitToWriteAsync, including the waits that ChannelReader<T>.ReadAllAsync makes) when the token passed to that wait is cancelled. It does this from a cancellation callback that queues the completion to the real thread pool: UnboundedChannel<T>'s CancellationCallbackDelegate calls ChannelUtilities.UnsafeQueueUserWorkItem, and the bounded channel behaves the same way.
When rewritten code cancels the token, even through the controlled CancellationTokenSource.Cancel, the waiter's value task completes on a thread-pool thread at a nondeterministic time. The controlled awaiter polls the value task's status, so the run usually observes the completion, but the step at which it becomes ready depends on real thread-pool timing.
How it was found
The thread-pool escape guard added in #57 (ThreadPoolEscapeGuard, an EventListener on FrameworkEventSource.ThreadPoolEnqueueWork) caught it in ChannelConformanceTests.ScenarioHasTheBclOutcome(combine/{method,enumeration,same}/pending). The enqueue's stack:
System.Threading.ThreadPool.UnsafeQueueUserWorkItem[TState](...)
System.Threading.Channels.ChannelUtilities.UnsafeQueueUserWorkItem[TState](...)
System.Threading.Channels.UnboundedChannel`1.<get_CancellationCallbackDelegate>b__13_0(Object state, CancellationToken cancellationToken)
System.Threading.CancellationTokenSource.ExecuteCallbackHandlers(Boolean throwOnFirstException)
Clockwork.Runtime.Tasks.SimulationCompletion ... Cancel
#57 turns the guard off for those three scenarios, with a reference to this issue.
Possible fix
Don't pass the token to a built-in channel's wait. Instead, race the uncancellable wait against the token in a controlled operation, as Task.WaitAsync does (SimulationTaskCompletionRace). Then remove the waiter, or let a later write consume it, so the channel's state matches the BCL's.
- 主要言語
- C#
- スター
- 0
- フォーク
- 0
- 平均マージ
- 2時間 32分
- マージ済み PR(30日)
- 23
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ReubenBond/Clockwork のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ReubenBond/Clockwork#73 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
ReubenBond/Clockwork#70 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 54/100
ReubenBond/Clockwork#77 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
ReubenBond/Clockwork#78 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 43/100
ReubenBond/Clockwork#76 ·
メンテナーはふだん 1 日以内に返信
ReubenBond/Clockwork の issue をすべて見る
似ている issue
-
[Bug]: Threading.Analyzers 0.7.79 does not load on the .NET 10 SDK (CS9057), CHT rules silently offオープンbug regression threading
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
CryptoHives/Foundation#362 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: 本地歌词翻译显示错误オープンbug need-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
Fervent-Tempo/AF-Media-Bar#321 ·
-
a-corriger documentation
難易度 1/5 1時間未満 初心者へのやさしさ 87/100
christian-raj/S-Aloha#345 ·
-
bug 要トリアージ
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
-
worldInstancedOccluderNode reads its appendix count as one byte, but it is a VLQ対応中かも @spuddeh が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信