Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
CoreCLR TieredCompilation JIT bug
> .\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
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];
set COMPlus_TieredCompilation=0
dotnet run -c Release
set COMPlus_TieredCompilation=1
dotnet run -c Release
<Project Sdk="Microsoft.NET.Sdk">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.