-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
52 additions
and
10 deletions.
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
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
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
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
42 changes: 42 additions & 0 deletions
42
src/tests/JIT/Regression/JitBlue/Runtime_64657/Runtime_64657.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,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.Runtime.InteropServices; | ||
using System.Runtime.CompilerServices; | ||
|
||
public class Runtime_64657 | ||
{ | ||
[DllImport("kernel32")] | ||
public static extern byte* VirtualAlloc(IntPtr lpAddress, nuint dwSize, uint flAllocationType, uint flProtect); | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
static void Validate<T>(T* c, int x) where T : unmanaged | ||
{ | ||
// this nullcheck should not read more than requested | ||
T implicitNullcheck = c[x]; | ||
} | ||
|
||
public static int Main() | ||
{ | ||
if (!OperatingSystem.IsWindows()) | ||
return 100; // VirtualAlloc is only for Windows | ||
|
||
uint length = (uint)Environment.SystemPageSize; | ||
byte* ptr = VirtualAlloc(IntPtr.Zero, length, 0x1000 | 0x2000 /* reserve commit */, 0x04 /*readonly guard*/); | ||
|
||
Validate((byte*)(ptr + length - sizeof(byte)), 0); | ||
Validate((sbyte*)(ptr + length - sizeof(sbyte)), 0); | ||
Validate((bool*)(ptr + length - sizeof(bool)), 0); | ||
Validate((ushort*)(ptr + length - sizeof(ushort)), 0); | ||
Validate((short*)(ptr + length - sizeof(short)), 0); | ||
Validate((uint*)(ptr + length - sizeof(uint)), 0); | ||
Validate((int*)(ptr + length - sizeof(int)), 0); | ||
Validate((ulong*)(ptr + length - sizeof(ulong)), 0); | ||
Validate((long*)(ptr + length - sizeof(long)), 0); | ||
Validate((nint*)(ptr + length - sizeof(nint)), 0); | ||
Validate((nuint*)(ptr + length - sizeof(nuint)), 0); | ||
|
||
return 100; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/tests/JIT/Regression/JitBlue/Runtime_64657/Runtime_64657.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,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
</Project> |