fix: a built-in channel's wait, cancelled by its token, completes on the real thread pool
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 43/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- csharp
- Ambito
- distributed-systems, testing-qa
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- C#
- Stelle
- 0
- Fork
- 0
- Merge medio
- 2h 32m
- PR unite (30g)
- 23
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ReubenBond/Clockwork
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
ReubenBond/Clockwork#73 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
ReubenBond/Clockwork#70 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 54/100
ReubenBond/Clockwork#77 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
ReubenBond/Clockwork#78 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 43/100
ReubenBond/Clockwork#76 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di ReubenBond/Clockwork
Issue simili
-
[Bug]: Threading.Analyzers 0.7.79 does not load on the .NET 10 SDK (CS9057), CHT rules silently offApertabug regression threading
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
CryptoHives/Foundation#362 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: 本地歌词翻译显示错误Apertabug need-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
Fervent-Tempo/AF-Media-Bar#321 ·
-
a-corriger documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 87/100
christian-raj/S-Aloha#345 ·
-
bug 要トリアージ
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
I maintainer di solito rispondono entro 1 giorno
-
worldInstancedOccluderNode reads its appendix count as one byte, but it is a VLQForse già presa @spuddeh l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno