Skip to content

Commit

Permalink
Use GetInt32ComPlusOrDotNetConfig and don't cache _stackSizeFromConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Keegan Caruso committed Feb 10, 2025
1 parent 2975db0 commit b6fd3f7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private unsafe bool CreateThread(GCHandle thisThreadHandle)

if (stackSize <= 0)
{
stackSize = _stackSizeFromConfig;
stackSize = GetDefaultStackSize();
}

if (!Interop.Sys.CreateThread((IntPtr)stackSize, &ThreadEntryPoint, (IntPtr)thisThreadHandle))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private unsafe bool CreateThread(GCHandle thisThreadHandle)

if (stackSize <= 0)
{
stackSize = _stackSizeFromConfig;
stackSize = GetDefaultStackSize();
}

if ((0 < stackSize) && (stackSize < AllocationGranularity))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,18 +483,16 @@ private static void StopThread(Thread thread)
}
}

private static int _stackSizeFromConfig = GetDefaultStackSize();

internal static int GetDefaultStackSize()
{
// Keep the same arbitrary minimum and maximum from the coreclr\vm layer.
// The max was 0x80000000 (2G).
// This is checked by the value being parsed into an int32.
const uint minStack = 0x10000; // 64K

int sizeFromConfig = AppContextConfigHelper.GetInt32Config(
int sizeFromConfig = AppContextConfigHelper.GetInt32ComPlusOrDotNetConfig(
"System.Threading.DefaultStackSize",
"DOTNET_Threading_DefaultStackSize",
"Threading_DefaultStackSize",
0,
false);

Expand Down

0 comments on commit b6fd3f7

Please sign in to comment.