Skip to content

Is profiler ReJIT of runtime-async method bodies intended to be supported on .NET 11 (preview 4)? #128944

Closed

Description

@birnbeidla

I am writing a small profiler that inserts IL code at beginning and end of certain methods.
It can do that at startup (in ModuleLoadFinished) or during runtime after specific triggers happen - triggering a rejit.

I have observed that the rejit variant does not work anymore as soon as the target method is a runtime async method -
but only if the method in question was already called before. (and therefore was jitted I guess)
I can confirm that the startup version is still working as intended.

The rejit is triggered using RequestReJITWithInliners, also COR_PRF_DISABLE_INLINING was set while testing.
While everything seems to work normally, the modified code just doesn't get applied.

Behavior after calling RequestReJITWithInliners:

  • RequestReJITWithInliners returns S_OK
  • GetReJITParameters gets called, call to SetILFunctionBody returns S_OK
  • ReJITError never gets called

Question:

Is this a known / intended behavior?

Activity

  1. added
    untriaged
    on Jun 3, 2026
  2. added
    area-CodeGen-coreclr
    on Jun 3, 2026
  3. dotnet-policy-service commented on Jun 3, 2026

    @dotnet-policy-service
    Contributor

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

  4. added and removed
    area-CodeGen-coreclr
    untriaged
    on Jun 4, 2026
  5. dotnet-policy-service commented on Jun 4, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
    See info in area-owners.md if you want to be subscribed.

  6. birnbeidla commented on Jun 12, 2026

    @birnbeidla
    Author

    I ran the same tests on preview 5 with the same result.

    Agentic research suggests that thunks are not updated on rejit. (Although I'm not sure how much I can rely on that)

    Any thoughts though? Any comments from other people that have tested profiler rejit?

  7. omerkoskas commented on Jul 1, 2026

    @omerkoskas

    Hey, I'm noticing this issue as well, any news here?

  8. hans-juergenkleeber commented on Jul 2, 2026

    @hans-juergenkleeber

    Hey, I put together a minimal self-contained reproducer, see the attached zip.

    It's a small C++ profiler + C# app that makes the problem immediately visible:

    • .\run.ps1 before - ReJIT applied before the first call -> works, injected IL runs
    • .\run.ps1 after - ReJIT applied after the method was already called -> silently does nothing; the profiler log shows RequestReJITWithInliners -> OK, SetILFunctionBody -> OK, ReJITCompilationFinished -> hrStatus=0 but the original code keeps running

    Requires DOTNET_RuntimeAsync=1 (set by the script), .NET SDK 11.0.100-preview.4, CMake, and VS 2022. .\build.ps1 then .\run.ps1 before|after.

    simple-runtime-async-rejit.zip

  9. added this to the 11.0.0 milestone on Jul 2, 2026
  10. self-assigned this
    on Jul 21, 2026
  11. locked and limited conversation to collaborators on Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions