Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Fix an assertion failure in the thread pool's QueueUserWorkItemCallba…
Browse files Browse the repository at this point in the history
…ckBase (#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

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
  • Loading branch information
kouvel authored and safern committed Jul 1, 2019
1 parent cd74e96 commit 70418e5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Common/src/CoreLib/System/Threading/ThreadPool.cs
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 70418e5

Please sign in to comment.