Skip to content

Commit

Permalink
InitFlsSlot throws per convention used in threading initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
VSadov committed Dec 11, 2024
1 parent 6da70e0 commit dfcaf7c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
7 changes: 3 additions & 4 deletions src/coreclr/vm/ceemain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1759,17 +1759,16 @@ static void __stdcall FiberDetachCallback(void* lpFlsData)
}
}

bool InitFlsSlot()
void InitFlsSlot()
{
// We use fiber detach callbacks to run our thread shutdown code because the fiber detach
// callback is made without the OS loader lock
g_flsIndex = FlsAlloc(FiberDetachCallback);
if (g_flsIndex == FLS_OUT_OF_INDEXES)
{
return false;
_ASSERTE(!"Initialization of an FLS slot failed.");
COMPlusThrowWin32();
}

return true;
}

// Register the thread with OS to be notified when thread is about to be destroyed
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/ceemain.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void ThreadDetaching();

void EnsureTlsDestructionMonitor();
#ifdef TARGET_WINDOWS
bool InitFlsSlot();
void InitFlsSlot();
bool OsDetachThread(void* thread);
#endif

Expand Down
5 changes: 1 addition & 4 deletions src/coreclr/vm/threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1049,10 +1049,7 @@ void InitThreadManager()
CONTRACTL_END;

#ifdef TARGET_WINDOWS
if (!InitFlsSlot())
{
_ASSERTE_ALL_BUILDS(!"Initialization of a FLS slot failed.");
}
InitFlsSlot();
#endif

// All patched helpers should fit into one page.
Expand Down

0 comments on commit dfcaf7c

Please sign in to comment.