Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Test] Add logging and fail-fast option when a thread is reinitialized after cleanup #110977

Draft
wants to merge 1 commit into
base: release/9.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/coreclr/inc/clrconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ RETAIL_CONFIG_DWORD_INFO(INTERNAL_Thread_DeadThreadCountThresholdForGCTrigger, W
RETAIL_CONFIG_DWORD_INFO(INTERNAL_Thread_DeadThreadGCTriggerPeriodMilliseconds, W("Thread_DeadThreadGCTriggerPeriodMilliseconds"), 1000 * 60 * 30, "In the heuristics to clean up dead threads, this much time must have elapsed since the previous max-generation GC before triggering another GC will be considered")
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_Thread_UseAllCpuGroups, W("Thread_UseAllCpuGroups"), 0, "Specifies whether to query and use CPU group information for determining the processor count.")
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_Thread_AssignCpuGroups, W("Thread_AssignCpuGroups"), 1, "Specifies whether to automatically distribute threads created by the CLR across CPU Groups. Effective only when Thread_UseAllCpuGroups and GCCpuGroup are enabled.")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_Thread_FailFastOnReinitialize, W("Thread_FailFastOnReinitialize"), 0, "Triggers a fail-fast if a thread is reinitialized after cleanup")
RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_ProcessorCount, W("PROCESSOR_COUNT"), 0, "Specifies the number of processors available for the process, which is returned by Environment.ProcessorCount", CLRConfig::LookupOptions::ParseIntegerAsBase10)

///
Expand Down
12 changes: 12 additions & 0 deletions src/coreclr/vm/ceemain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1710,16 +1710,28 @@ BOOL STDMETHODCALLTYPE EEDllMain( // TRUE on success, FALSE on error.
struct TlsDestructionMonitor
{
bool m_activated = false;
bool m_destructorCalled = false;

void Activate()
{
if (m_destructorCalled)
{
STRESS_LOG1(LF_STARTUP, LL_FATALERROR, "%s", "Thread is being reinitialized after cleanup");
if (CLRConfig::GetConfigValue(CLRConfig::INTERNAL_Thread_FailFastOnReinitialize) != 0)
{
_ASSERTE_ALL_BUILDS(!"Thread is being reinitialized after cleanup");
}
}

m_activated = true;
}

~TlsDestructionMonitor()
{
if (m_activated)
{
m_destructorCalled = true;

Thread* thread = GetThreadNULLOk();
if (thread)
{
Expand Down
Loading