diff options
author | Koundinya Veluri <kouvel@users.noreply.github.com> | 2019-06-28 13:08:22 -0700 |
---|---|---|
committer | Stephen Toub <stoub@microsoft.com> | 2019-06-28 16:08:22 -0400 |
commit | c191f92b30e212b7638e0ae3b71240c73991b369 (patch) | |
tree | bd98952e8ec7c4fc5c3df20d20b1387cc1c8ca6a /src/System.Private.CoreLib | |
parent | 141d587472ee2fe6ab522c603c352936defeaac3 (diff) | |
download | coreclr-c191f92b30e212b7638e0ae3b71240c73991b369.tar.gz coreclr-c191f92b30e212b7638e0ae3b71240c73991b369.tar.bz2 coreclr-c191f92b30e212b7638e0ae3b71240c73991b369.zip |
Fix an assertion failure in the thread pool's QueueUserWorkItemCallbackBase (#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
Diffstat (limited to 'src/System.Private.CoreLib')
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Threading/ThreadPool.cs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Threading/ThreadPool.cs b/src/System.Private.CoreLib/shared/System/Threading/ThreadPool.cs index 064227bf51..dca22ab35a 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/ThreadPool.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/ThreadPool.cs @@ -770,11 +770,12 @@ namespace System.Threading 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!"); } |