Created
September 19, 2018 02:33
-
-
Save ReubenBond/b5bdf98423d5279a8e9ae63a5e6e8f0a to your computer and use it in GitHub Desktop.
CoreCLR TieredCompilation JIT bug
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
> .\repro.cmd | |
C:\tmp\TieredJit\TierJit\TierJit>set COMPlus_TieredCompilation=0 | |
C:\tmp\TieredJit\TierJit\TierJit>dotnet run -c Release | |
Correct value: True | |
C:\tmp\TieredJit\TierJit\TierJit>set COMPlus_TieredCompilation=1 | |
C:\tmp\TieredJit\TierJit\TierJit>dotnet run -c Release | |
Correct value: False |
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
using System; | |
namespace TierJit | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var array = new byte[] {0x00, 0x01}; | |
var reader = new BinaryTokenStreamReader(array); | |
var val = reader.ReadByte(); | |
// Prints true if tiered jit is disabled | |
// and false if tiered jit is enabled. | |
Console.WriteLine("Correct value: " + (val == 0x01)); | |
} | |
} | |
public class BinaryTokenStreamReader | |
{ | |
private readonly byte[] currentBuffer; | |
public BinaryTokenStreamReader(byte[] input) | |
{ | |
this.currentBuffer = input; | |
} | |
byte[] CheckLength(out int offset) | |
{ | |
// In the original code, this logic is more complicated. | |
// It's simplified here to demonstrate the bug. | |
offset = 1; | |
return currentBuffer; | |
} | |
public byte ReadByte() | |
{ | |
int offset; | |
var buff = CheckLength(out offset); | |
return buff[offset]; | |
} | |
} | |
} |
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
set COMPlus_TieredCompilation=0 | |
dotnet run -c Release | |
set COMPlus_TieredCompilation=1 | |
dotnet run -c Release |
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
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>netcoreapp2.1</TargetFramework> | |
</PropertyGroup> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment