forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes issue dotnet#51612 (dotnet#52231)
* Add regression test for dotnet#51612 * Allocate a dummy local when an inlinee needs GSCookie but the root method does not in src/coreclr/jit/fginline.cpp
- Loading branch information
Showing
3 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
src/tests/JIT/Regression/JitBlue/Runtime_51612/Runtime_51612.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// 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.Runtime.CompilerServices; | ||
|
||
namespace Runtime_51612 | ||
{ | ||
class Program | ||
{ | ||
struct PassedViaReturnBuffer | ||
{ | ||
public int _0; | ||
public int _1; | ||
} | ||
|
||
abstract class Base | ||
{ | ||
public unsafe abstract PassedViaReturnBuffer HasEspBasedFrame(); | ||
} | ||
|
||
class Derived : Base | ||
{ | ||
public Derived(Exception ex) | ||
{ | ||
_ex = ex; | ||
} | ||
|
||
readonly Exception _ex; | ||
|
||
public override PassedViaReturnBuffer HasEspBasedFrame() | ||
{ | ||
DoesNotReturn(); | ||
PassedViaReturnBuffer retBuf; | ||
retBuf = RequiresGuardStack(); | ||
return retBuf; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
static unsafe PassedViaReturnBuffer RequiresGuardStack() | ||
{ | ||
int* p = stackalloc int[2]; | ||
|
||
p[0] = 1; | ||
p[1] = 2; | ||
|
||
PassedViaReturnBuffer retBuf; | ||
|
||
retBuf._0 = p[0]; | ||
retBuf._1 = p[1]; | ||
|
||
return retBuf; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
void DoesNotReturn() | ||
{ | ||
throw _ex; | ||
} | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
static void AssertsThatGuardStackCookieOffsetIsInvalid(Base x) | ||
{ | ||
x.HasEspBasedFrame(); | ||
} | ||
|
||
static int Main(string[] args) | ||
{ | ||
try | ||
{ | ||
AssertsThatGuardStackCookieOffsetIsInvalid(new Derived(new Exception())); | ||
} | ||
catch (Exception ex) | ||
{ | ||
return 100; | ||
} | ||
|
||
return 0; | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/tests/JIT/Regression/JitBlue/Runtime_51612/Runtime_51612.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<DebugType>None</DebugType> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
</Project> |