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

Commit

Permalink
Initalize threadpool statics in SecuritySafeCritical path
Browse files Browse the repository at this point in the history
  • Loading branch information
benaadams committed Feb 12, 2016
1 parent b2026f3 commit 4ec573b
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/mscorlib/src/System/Threading/ThreadPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ internal static class ThreadPoolGlobals
public static bool enableWorkerTracking;

[SecurityCritical]
public static ThreadPoolWorkQueue workQueue = InitWorkQueue();
public static ThreadPoolWorkQueue workQueue;

[SecurityCritical]
private static ThreadPoolWorkQueue InitWorkQueue()
internal static void Initialize()
{
return new ThreadPoolWorkQueue();
workQueue = new ThreadPoolWorkQueue();
}
}

Expand Down Expand Up @@ -1247,12 +1247,12 @@ void IThreadPoolWorkItem.MarkAborted(ThreadAbortException tae)
}

[System.Security.SecurityCritical]
static internal ContextCallback ccb = InitCallbackContext();
static internal ContextCallback ccb;

[System.Security.SecurityCritical]
static private ContextCallback InitCallbackContext()
static internal void Initialize()
{
return new ContextCallback(WaitCallback_Context);
ccb = new ContextCallback(WaitCallback_Context);
}

[System.Security.SecurityCritical]
Expand All @@ -1271,14 +1271,15 @@ internal class _ThreadPoolWaitOrTimerCallback
ExecutionContext _executionContext;
Object _state;
[System.Security.SecurityCritical]
static private ContextCallback _ccbt = new ContextCallback(WaitOrTimerCallback_Context_t);
static private ContextCallback _ccbt;
[System.Security.SecurityCritical]
static private ContextCallback _ccbf = InitCallbackContext();
static private ContextCallback _ccbf;

[System.Security.SecurityCritical]
static private ContextCallback InitCallbackContext()
static internal void Initialize()
{
return new ContextCallback(WaitOrTimerCallback_Context_f);
_ccbt = new ContextCallback(WaitOrTimerCallback_Context_t);
_ccbf = new ContextCallback(WaitOrTimerCallback_Context_f);
}

[System.Security.SecurityCritical] // auto-generated
Expand Down Expand Up @@ -1795,6 +1796,11 @@ private static void EnsureVMInitialized()
if (!ThreadPoolGlobals.vmTpInitialized)
{
ThreadPool.InitializeVMTp(ref ThreadPoolGlobals.enableWorkerTracking);

ThreadPoolGlobals.Initialize();
QueueUserWorkItemCallback.Initialize();
_ThreadPoolWaitOrTimerCallback.Initialize();

ThreadPoolGlobals.vmTpInitialized = true;
}
}
Expand Down

0 comments on commit 4ec573b

Please sign in to comment.