Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT ARM64: Funclets with "frame type 5" not handled correctly #66089

Closed
jakobbotsch opened this issue Mar 2, 2022 · 5 comments · Fixed by #70922
Closed

JIT ARM64: Funclets with "frame type 5" not handled correctly #66089

jakobbotsch opened this issue Mar 2, 2022 · 5 comments · Fixed by #70922
Assignees
Labels
arch-arm64 area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone

Comments

@jakobbotsch
Copy link
Member

jakobbotsch commented Mar 2, 2022

Description

Funclets with large frame sizes in functions using stackalloc use an unusual kind of frame. The JIT does not generate correct prolog code for these funclets.

Reproduction Steps

using System;
using System.Runtime.CompilerServices;

public class Program
{
    public static unsafe void Main()
    {
        int* foo = stackalloc int[30];
        try
        {
            Console.WriteLine("try");
            throw new Exception();
        }
        catch (Exception)
        {
            Console.WriteLine("catch");
            foo[0] = 10;
            ManyArgs(new Guid(foo[0], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
        }
        Console.WriteLine("after");
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    private static void ManyArgs(
        Guid g0 = default,
        Guid g1 = default,
        Guid g2 = default,
        Guid g3 = default,
        Guid g4 = default,
        Guid g5 = default,
        Guid g6 = default,
        Guid g7 = default,
        Guid g8 = default,
        Guid g9 = default,
        Guid g10 = default,
        Guid g11 = default,
        Guid g12 = default,
        Guid g13 = default,
        Guid g14 = default,
        Guid g15 = default,
        Guid g16 = default,
        Guid g17 = default,
        Guid g18 = default,
        Guid g19 = default,
        Guid g20 = default,
        Guid g21 = default,
        Guid g22 = default,
        Guid g23 = default,
        Guid g24 = default,
        Guid g25 = default,
        Guid g26 = default,
        Guid g27 = default,
        Guid g28 = default,
        Guid g29 = default,
        Guid g30 = default,
        Guid g31 = default,
        Guid g32 = default,
        Guid g33 = default,
        Guid g34 = default,
        Guid g35 = default,
        Guid g36 = default,
        Guid g37 = default,
        Guid g38 = default,
        Guid g39 = default,
        Guid g40 = default,
        Guid g41 = default)
    {
    }
}

Expected behavior

Prints "try", "catch" and "after".

Actual behavior

"after" is not printed.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

The JIT generates the following prolog for the funclet:

G_M27646_IG06:              ;; offset=00C0H
        F90007F3          str     x19, [sp,#8]
        A9017BFD          stp     fp, lr, [sp,#16]
        D10983FF          sub     sp, sp, #608
        910043A3          add     x3, fp, #16
        F90133E3          str     x3, [sp,#608]

This overrides caller stack with callee saves.

cc @dotnet/jit-contrib

@jakobbotsch jakobbotsch added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Mar 2, 2022
@jakobbotsch jakobbotsch added this to the 7.0.0 milestone Mar 2, 2022
@ghost
Copy link

ghost commented Mar 2, 2022

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

Issue Details

Description

Funclets with large frame sizes in functions using stackalloc use an unusual kind of frame. The JIT does not generate correct prolog code for these funclets.

Reproduction Steps

using System;
using System.Runtime.CompilerServices;

public class Program
{
    public static unsafe void Main()
    {
        int* foo = stackalloc int[30];
        try
        {
            Console.WriteLine("try");
            throw new Exception();
        }
        catch (Exception)
        {
            Console.WriteLine("catch");
            foo[0] = 10;
            ManyArgs(new Guid(foo[0], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
        }
        Console.WriteLine("after");
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    private static void ManyArgs(
        Guid g0 = default,
        Guid g1 = default,
        Guid g2 = default,
        Guid g3 = default,
        Guid g4 = default,
        Guid g5 = default,
        Guid g6 = default,
        Guid g7 = default,
        Guid g8 = default,
        Guid g9 = default,
        Guid g10 = default,
        Guid g11 = default,
        Guid g12 = default,
        Guid g13 = default,
        Guid g14 = default,
        Guid g15 = default,
        Guid g16 = default,
        Guid g17 = default,
        Guid g18 = default,
        Guid g19 = default,
        Guid g20 = default,
        Guid g21 = default,
        Guid g22 = default,
        Guid g23 = default,
        Guid g24 = default,
        Guid g25 = default,
        Guid g26 = default,
        Guid g27 = default,
        Guid g28 = default,
        Guid g29 = default,
        Guid g30 = default,
        Guid g31 = default,
        Guid g32 = default,
        Guid g33 = default,
        Guid g34 = default,
        Guid g35 = default,
        Guid g36 = default,
        Guid g37 = default,
        Guid g38 = default,
        Guid g39 = default,
        Guid g40 = default,
        Guid g41 = default)
    {
    }
}
` `

### Expected behavior

Prints "try", "catch" and "after".

### Actual behavior

"after" is not printed.

### Regression?

_No response_

### Known Workarounds

_No response_

### Configuration

_No response_

### Other information

The JIT generates the following prolog for the funclet:

```asm
G_M27646_IG06:              ;; offset=00C0H
        F90007F3          str     x19, [sp,#8]
        A9017BFD          stp     fp, lr, [sp,#16]
        D10983FF          sub     sp, sp, #608
        910043A3          add     x3, fp, #16
        F90133E3          str     x3, [sp,#608]

This overrides caller stack with fp/lr.

cc @dotnet/jit-contrib

Author: jakobbotsch
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: 7.0.0

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Mar 2, 2022
@AndyAyersMS
Copy link
Member

Also worth noting that very large funclet frames won't do stack probing. OSR hits this in GitHub_21999 because it has to pad the funclet frame with the Tier0 frame size.

@BruceForstall BruceForstall removed the untriaged New issue has not been triaged by the area owner label Mar 3, 2022
@JulieLeeMSFT
Copy link
Member

Assigining Arm64 issues to @kunalspathak. Please redistrubte to members.

@BruceForstall
Copy link
Member

@kunalspathak Can I take this?

@kunalspathak
Copy link
Member

Sure

@ghost ghost locked as resolved and limited conversation to collaborators Jul 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-arm64 area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants