Skip to content

[release/11.0-preview6] Fix async resumption stub with byref parameters#130022

Open
github-actions[bot] wants to merge 3 commits into
release/11.0-preview6from
backport/pr-129999-to-release/11.0-preview6
Open

[release/11.0-preview6] Fix async resumption stub with byref parameters#130022
github-actions[bot] wants to merge 3 commits into
release/11.0-preview6from
backport/pr-129999-to-release/11.0-preview6

Conversation

@github-actions

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

Copy link
Copy Markdown
Contributor

Backport of #129999 to release/11.0-preview6

/cc @jakobbotsch

Customer Impact

  • Customer reported
  • Found internally

A Task-returning method A with a byref parameter may cause the runtime to throw an InvalidProgramException if directly returning the result of another Task-returning method B(), the task returned by B suspends and also one of the following is true:

  • A is marked with [MethodImpl(MethodImplOptions.NoInlining)]
  • B returns Task<T> and A returns Task

In these cases the runtime produces an internal IL stub with invalid IL. The invalid IL tries to zero a byref local using initobj, which is not legal IL. Reported by ASP.NET in #129990.

Regression

  • Yes
  • No

This issue exists since runtime async was introduced, but #128384 made it possible to hit this issue from C# code.

Testing

Unit test introduced.

Risk

Low. Adjust IL emission to load a byref zero without initobj.

It is not valid IL to initialize a byref local with `initobj`. Just load
the value of these directly.

We had a test for byref parameters, but it did not suspend and did not
result in creation of a resumption stub. The test case requires
suspension + NoInlining to guarantee a suspension point is created.
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

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.

1 participant