Skip to content

Commit

Permalink
Fix an assertion failure in the thread pool's QueueUserWorkItemCallba…
Browse files Browse the repository at this point in the history
…ckBase (dotnet#25482)

Fixes https://github.com/dotnet/coreclr/issues/25242
- The issue could be that there is no memory barrier (or in the wrong place) on the thread reading the value, and an old value could be cached and read
  • Loading branch information
kouvel authored and stephentoub committed Jun 28, 2019
1 parent 141d587 commit c191f92
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -770,11 +770,12 @@ public ThreadPoolWorkQueueThreadLocals(ThreadPoolWorkQueue tpq)
internal abstract class QueueUserWorkItemCallbackBase : IThreadPoolWorkItem
{
#if DEBUG
private volatile int executed;
private int executed;

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1821:RemoveEmptyFinalizers")]
~QueueUserWorkItemCallbackBase()
{
Interlocked.MemoryBarrier(); // ensure that an old cached value is not read below
Debug.Assert(
executed != 0, "A QueueUserWorkItemCallback was never called!");
}
Expand Down

0 comments on commit c191f92

Please sign in to comment.