fix: a built-in channel's wait, cancelled by its token, completes on the real thread pool
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 43/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- csharp
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C#
- Estrellas
- 0
- Forks
- 0
- Merge medio
- 2 h 32 min
- PR fusionados (30 d)
- 23
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de ReubenBond/Clockwork
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
ReubenBond/Clockwork#73 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
ReubenBond/Clockwork#70 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 54/100
ReubenBond/Clockwork#77 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
ReubenBond/Clockwork#78 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 43/100
ReubenBond/Clockwork#76 ·
Los mantenedores suelen responder en 1 día
Todos los issues de ReubenBond/Clockwork
Issues similares
-
[Bug]: Threading.Analyzers 0.7.79 does not load on the .NET 10 SDK (CS9057), CHT rules silently offAbiertobug regression threading
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
CryptoHives/Foundation#362 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: 本地歌词翻译显示错误Abiertobug need-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Fervent-Tempo/AF-Media-Bar#321 ·
-
a-corriger documentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 87/100
christian-raj/S-Aloha#345 ·
-
bug 要トリアージ
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
Los mantenedores suelen responder en 1 día
-
worldInstancedOccluderNode reads its appendix count as one byte, but it is a VLQPosiblemente ocupada @spuddeh la tomó hoy. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día