Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Sollich <petersol@microsoft.com>2017-08-21 11:38:36 +0300
committerPeter Sollich <petersol@microsoft.com>2017-08-21 11:38:36 +0300
commit7c1551d4c6606e5eb106bba2cd379d03fa08e9f8 (patch)
treee4b061385d8982ba0d4ff88bf53de6536f3606b6 /src/Native
parent52e15b8fc4497582dd1112b01c46c76f6203e1b3 (diff)
This fixes the stresslog issue with the chk version of mrt150.dll that Sergiy mentioned. The problem was that the thread structure was not properly initialized for the special GC threads in server GC.
Seeing that the threads in server GC start out by calling "ClrFlsSetThreadType (ThreadType_GC)", I made that call do the required initialization by adding appropriate macro definitions and declarations to gcenv.h and an implementation to gcrhenv.cpp. I also mplemented IsGCSpecialThread for background GC by testing the flag on the thread, as well as IsGCThread. [tfs-changeset: 1671185]
Diffstat (limited to 'src/Native')
-rw-r--r--src/Native/Runtime/gcenv.h9
-rw-r--r--src/Native/Runtime/gcrhenv.cpp14
-rw-r--r--src/Native/Runtime/thread.cpp2
3 files changed, 23 insertions, 2 deletions
diff --git a/src/Native/Runtime/gcenv.h b/src/Native/Runtime/gcenv.h
index f5a369721..557103dbc 100644
--- a/src/Native/Runtime/gcenv.h
+++ b/src/Native/Runtime/gcenv.h
@@ -241,6 +241,15 @@ typedef DPTR(uint32_t) PTR_uint32_t;
enum CLRDataEnumMemoryFlags : int;
+enum ThreadType
+{
+ ThreadType_GC = 137,
+};
+
+#undef ClrFlsSetThreadType
+#define ClrFlsSetThreadType(threadType) SetGCSpecialThread(threadType)
+void SetGCSpecialThread(ThreadType threadType);
+
#if defined(ENABLE_PERF_COUNTERS) || defined(FEATURE_EVENT_TRACE)
// Note this is not updated in a thread safe way so the value may not be accurate. We get
// it accurately in full GCs if the handle count is requested.
diff --git a/src/Native/Runtime/gcrhenv.cpp b/src/Native/Runtime/gcrhenv.cpp
index 30ac3210c..477661a68 100644
--- a/src/Native/Runtime/gcrhenv.cpp
+++ b/src/Native/Runtime/gcrhenv.cpp
@@ -1259,11 +1259,13 @@ gc_alloc_context * Thread::GetAllocContext()
return dac_cast<DPTR(gc_alloc_context)>(dac_cast<TADDR>(this) + offsetof(Thread, m_rgbAllocContextBuffer));
}
+#ifndef DACCESS_COMPILE
bool IsGCSpecialThread()
{
// TODO: Implement for background GC
- return false;
+ return ThreadStore::GetCurrentThread()->IsGCSpecial();
}
+#endif // DACCESS_COMPILE
GPTR_IMPL(Thread, g_pFinalizerThread);
GPTR_IMPL(Thread, g_pGcThread);
@@ -1280,15 +1282,23 @@ bool __SwitchToThread(uint32_t dwSleepMSec, uint32_t /*dwSwitchCount*/)
return !!PalSwitchToThread();
}
+void SetGCSpecialThread(ThreadType threadType)
+{
+ Thread *pThread = ThreadStore::RawGetCurrentThread();
+ pThread->SetGCSpecial(threadType == ThreadType_GC);
+}
+
#endif // DACCESS_COMPILE
MethodTable * g_pFreeObjectMethodTable;
int32_t g_TrapReturningThreads;
+#ifndef DACCESS_COMPILE
bool IsGCThread()
{
- return false;
+ return IsGCSpecialThread() || ThreadStore::GetSuspendingThread() == ThreadStore::GetCurrentThread();
}
+#endif // DACCESS_COMPILE
void LogSpewAlways(const char * /*fmt*/, ...)
{
diff --git a/src/Native/Runtime/thread.cpp b/src/Native/Runtime/thread.cpp
index 6f970a46d..2c64a22fa 100644
--- a/src/Native/Runtime/thread.cpp
+++ b/src/Native/Runtime/thread.cpp
@@ -334,6 +334,8 @@ bool Thread::IsInitialized()
//
void Thread::SetGCSpecial(bool isGCSpecial)
{
+ if (!IsInitialized())
+ Construct();
if (isGCSpecial)
SetState(TSF_IsGcSpecialThread);
else