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

Non-blittable struct with explicit layout has wrong managed size #100220

Closed
jkotas opened this issue Mar 25, 2024 · 3 comments · Fixed by #100289
Closed

Non-blittable struct with explicit layout has wrong managed size #100220

jkotas opened this issue Mar 25, 2024 · 3 comments · Fixed by #100289

Comments

@jkotas
Copy link
Member

jkotas commented Mar 25, 2024

Context #100206 (comment)

Repro

using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;

Console.WriteLine(Unsafe.SizeOf<MyStruct>());

[StructLayout(LayoutKind.Explicit, Size = 9)]
struct MyStruct
{
    [FieldOffset(0)]
    public byte[] a;
    [FieldOffset(8)]
    public byte b;
}

Expected result (on x64)

16

Actual result

9

Copy link
Contributor

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

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Mar 25, 2024
@MichalStrehovsky
Copy link
Member

The layout logic is shared with crossgen2; this also reproes with ReadyToRun.

The type layout has been owned/worked on by the crossgen2 team since it needs to be bug-for-bug compatible with CoreCLR VM type system for ReadyToRun to work. Moving to crossgen2 area path.

@MichalStrehovsky MichalStrehovsky changed the title [NativeAOT] Non-blittable struct with explicit layout has wrong managed size Non-blittable struct with explicit layout has wrong managed size Mar 25, 2024
@steveisok
Copy link
Member

/cc @kg

@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Apr 10, 2024
@github-actions github-actions bot locked and limited conversation to collaborators May 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants