Skip to content

JIT: Assertion failed 'isValidGeneralDatasize(size)' during 'Generate code' #132268

Description

@jakobbotsch
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

public static unsafe class Program
{
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private static ref byte GetNonNullPinnableReference(Span<byte> buffer)
    {
        return ref buffer.Length != 0 ? ref MemoryMarshal.GetReference(buffer) : ref Unsafe.AsRef<byte>((void*)1);
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    private static int Consume(byte* p, int length) => p is null ? -1 : length;

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private static int Pin(Span<byte> destination)
    {
        fixed (byte* p = &GetNonNullPinnableReference(destination))
        {
            int status = Consume(p, destination.Length);

            if (status != 0)
            {
                throw new InvalidOperationException();
            }

            return status;
        }
    }

    public static int Main()
    {
        int result = Pin(default);
        Console.WriteLine($"Pin(default) = {result}");
        return result == 0 ? 100 : 1;
    }
}
src\coreclr\jit\emitarm64.cpp:3025
Assertion failed 'isValidGeneralDatasize(size)' in 'Program:Main():int' during 'Generate code' (IL size 65; hash 0xd9b8a0c8; FullOpts)

Reproduces only with crossgen2/ilc.

I hit this in a less-contrived example in #131538.

Activity

  1. added
    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
    on Aug 13, 2026
  2. dotnet-policy-service commented on Aug 13, 2026

    @dotnet-policy-service
    Contributor

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

  3. removed
    untriagedNew issue has not been triaged by the area owner
    on Aug 13, 2026
  4. added this to the 11.0.0 milestone on Aug 13, 2026
  5. locked and limited conversation to collaborators on Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions