Skip to content

[release/10.0] Fix UnsafeAccessor signature for byref struct this#128851

Merged
JulieLeeMSFT merged 14 commits into
release/10.0from
backport/pr-122754-to-release/10.0
Jun 3, 2026
Merged

[release/10.0] Fix UnsafeAccessor signature for byref struct this#128851
JulieLeeMSFT merged 14 commits into
release/10.0from
backport/pr-122754-to-release/10.0

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented Jun 1, 2026

Backport of #122754 to release/10.0

/cc @AaronRobinsonMSFT @hez2010

Customer Impact

  • Customer reported
  • Found internally

This was reported twice by the community and fixed early in .NET 11. It wasn't backported to .NET 10 at the time.

Fixes #122678
Fixes #128806

Motivating example:

using System.Runtime.CompilerServices;

S<int> sInt32 = new();
Accessor<int>.M(ref sInt32);
Console.WriteLine("Int32 okay");

S<string> sString = new();
Accessor<string>.M(ref sString); // <- Will cause an A/V
Console.WriteLine("string okay");

public struct S<T>
{
    private void M() { }
}

public static class Accessor<T>
{
    [UnsafeAccessor(UnsafeAccessorKind.Method, Name = "M")]
    public static extern void M(ref S<T> s);
}

Regression

  • Yes
  • No

This was a latent issue found with generic support.

Testing

A test was added.

Risk

Low. This has been in .NET 11 for quite some time. Porting to .NET 10 due to additional customer impact.

@AaronRobinsonMSFT AaronRobinsonMSFT added this to the 10.0.x milestone Jun 1, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.

@JulieLeeMSFT
Copy link
Copy Markdown
Member

@AaronRobinsonMSFT, please check test failures.

@AaronRobinsonMSFT
Copy link
Copy Markdown
Member

@JulieLeeMSFT None of these are related. They seem to be have something to do with iOS apps and system resources.

@AaronRobinsonMSFT
Copy link
Copy Markdown
Member

@JulieLeeMSFT I've checked and none of the failures appear related. I've just updated the base again.

@AaronRobinsonMSFT
Copy link
Copy Markdown
Member

@JulieLeeMSFT or @steveisok This is as green as it can get. Please merge this in.

@JulieLeeMSFT
Copy link
Copy Markdown
Member

/ba-g all known issues.

@JulieLeeMSFT JulieLeeMSFT merged commit 29b4872 into release/10.0 Jun 3, 2026
101 of 104 checks passed
@JulieLeeMSFT JulieLeeMSFT deleted the backport/pr-122754-to-release/10.0 branch June 3, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UnsafeAccessor on ReadOnlyMemory causes fatal ExecutionEngineException UnsafeAccessor with generic struct segfault

4 participants