-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
- Change stack size to 4MB on 64-bit desktop - Add tests to check stack size
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Runtime.CompilerServices; | ||
|
||
class Program | ||
{ | ||
[SkipLocalsInit] | ||
static int Main() | ||
Check failure on line 11 in src/tests/Regressions/coreclr/GitHub_87879/test87879.cs Azure Pipelines / runtime (Build mono Common Pri0 Test Build AnyOS AnyCPU release)src/tests/Regressions/coreclr/GitHub_87879/test87879.cs#L11
Check failure on line 11 in src/tests/Regressions/coreclr/GitHub_87879/test87879.cs Azure Pipelines / runtime (Build coreclr Common Pri0 Test Build AnyOS AnyCPU checked)src/tests/Regressions/coreclr/GitHub_87879/test87879.cs#L11
Check failure on line 11 in src/tests/Regressions/coreclr/GitHub_87879/test87879.cs Azure Pipelines / runtime (Build linux-x64 Release AllSubsets_Mono_LLVMAot_RuntimeTests llvmaot)src/tests/Regressions/coreclr/GitHub_87879/test87879.cs#L11
Check failure on line 11 in src/tests/Regressions/coreclr/GitHub_87879/test87879.cs Azure Pipelines / runtime (Build osx-x64 Release AllSubsets_Mono_Minijit_RuntimeTests minijit)src/tests/Regressions/coreclr/GitHub_87879/test87879.cs#L11
|
||
{ | ||
//determine the expected available stack size (4MB or 1MB), minus a little bit (384kB) for overhead. | ||
var expectedSize = (IntPtr.Size == 8 ? 0x4_00000 : 0x1_00000) - 0x60000; | ||
|
||
//allocate 4MB, minus a little bit (512kB) for overhead | ||
Span<byte> bytes = stackalloc byte[expectedSize]; | ||
Consume(bytes); | ||
Console.WriteLine("Main thread succeeded."); | ||
|
||
//repeat on a secondary thread | ||
Thread t = new Thread([SkipLocalsInit] () => | ||
{ | ||
Span<byte> bytes = stackalloc byte[expectedSize]; | ||
Consume(bytes); | ||
}); | ||
t.Start(); | ||
t.Join(); | ||
Console.WriteLine("Secondary thread succeeded."); | ||
|
||
//success | ||
return 100; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
static void Consume(Span<byte> bytes) | ||
{ | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<CLRTestTargetUnsupported>true</CLRTestTargetUnsupported> | ||
<CLRTestTargetUnsupported Condition="'$(TargetsWindows)' == 'true' OR ('$(TargetsUnix)' == 'true' AND '$(TargetsMobile)' != 'true')">false</CLRTestTargetUnsupported> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="test87879.cs" /> | ||
</ItemGroup> | ||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace DesktopStackSize | ||
{ | ||
class Program | ||
{ | ||
[SkipLocalsInit] | ||
static int Main() | ||
{ | ||
//determine the expected available stack size (4MB or 1MB), minus a little bit (384kB) for overhead. | ||
var expectedSize = (IntPtr.Size == 8 ? 0x4_00000 : 0x1_00000) - 0x60000; | ||
|
||
//allocate 4MB, minus a little bit (512kB) for overhead | ||
Span<byte> bytes = stackalloc byte[expectedSize]; | ||
Consume(bytes); | ||
Console.WriteLine("Main thread succeeded."); | ||
|
||
//repeat on a secondary thread | ||
Thread t = new Thread([SkipLocalsInit] () => | ||
{ | ||
Span<byte> bytes = stackalloc byte[expectedSize]; | ||
Consume(bytes); | ||
}); | ||
t.Start(); | ||
t.Join(); | ||
Console.WriteLine("Secondary thread succeeded."); | ||
|
||
//success | ||
return 100; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
static void Consume(Span<byte> bytes) | ||
{ | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<CLRTestTargetUnsupported>true</CLRTestTargetUnsupported> | ||
<CLRTestTargetUnsupported Condition="'$(TargetsWindows)' == 'true' OR ('$(TargetsUnix)' == 'true' AND '$(TargetsMobile)' != 'true')">false</CLRTestTargetUnsupported> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="DesktopStackSize.cs" /> | ||
</ItemGroup> | ||
</Project> |