Skip to content

JIT: (bug) GC poll insertion asserts when a poll lands in an EH-return block #134005

Closed

Description

@EgorBo

Minimal Repro

using System;
using System.Runtime.CompilerServices;

public class Program
{
    static object[] s_dst;

    [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
    public static void TestFinally()
    {
        try
        {
            Console.Write("");
        }
        finally
        {
            object[] a = new object[4];
            object[] b = new object[4];
            a[0] = a;
            s_dst = b;
            a.AsSpan().CopyTo(b.AsSpan());
        }
    }

    [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
    public static void TestCatch()
    {
        try
        {
            Console.Write("");
        }
        catch (Exception)
        {
            object[] a = new object[4];
            object[] b = new object[4];
            a[0] = a;
            s_dst = b;
            a.AsSpan().CopyTo(b.AsSpan());
        }
    }

    public static void Main(string[] args)
    {
        if (args.Length == 0 || args[0] == "finally") TestFinally();
        if (args.Length == 0 || args[0] == "catch") TestCatch();
        Console.WriteLine("done");
    }
}

Expected

done

Actual

Assert failure: Assertion failed
'block->KindIs(BBJ_RETURN, BBJ_ALWAYS, BBJ_COND, BBJ_SWITCH, BBJ_THROW, BBJ_CALLFINALLY)'
in 'Program:TestFinally()' during 'Insert GC Polls'
File: ...\src\coreclr\jit\flowgraph.cpp:118

Activity

  1. added this to the 12.0.0 milestone on Sep 15, 2026
  2. added
    area-CodeGen-coreclr
    on Sep 15, 2026
  3. dotnet-policy-service commented on Sep 15, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
    See info in area-owners.md if you want to be subscribed.

  4. changed the title [-]JIT (bug): GC poll insertion asserts when a poll lands in an EH-return block[/-] [+]JIT: (bug) GC poll insertion asserts when a poll lands in an EH-return block[/+] on Sep 16, 2026
  5. added a commit that references this issue on Sep 16, 2026
    5afad3f
  6. self-assigned this
    on Sep 16, 2026
  7. added a commit that references this issue on Sep 18, 2026
    ed20b06
  8. locked and limited conversation to collaborators on Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclr

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions