Skip to content

Passing large structs by value asserts/crashes on ARM32/x86 #12441

Closed
dotnet/coreclr
#23881
@mikedn

Description

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

class Program
{
    [StructLayout(LayoutKind.Sequential)]
    unsafe struct S
    {
        fixed byte x[65536];
    }

    class C
    {
        public S s;
    }

    static void Main() => Test(new C());

    [MethodImpl(MethodImplOptions.NoInlining)]
    static void Call(int r0, int r1, int r2, int r3, int r4, int r5, int r6, S s)
    {
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    static void Test(C c)
    {
        Call(0, 1, 2, 3, 4, 5, 42, c.s);
        Console.WriteLine("done");
    }
}

genPutArgStk is basically doing an unrolled copy and the emitter asserts because the offset is too large. It shouldn't do unroll, even for smaller structs.

Metadata

Metadata

Assignees

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