Skip to content

MacOS arm64 NAOT runtime-async - bad ResumeInfo written (causing failure on StackTraceTests) #124015

Closed

Activity

  1. dotnet-policy-service commented on Feb 4, 2026

    @dotnet-policy-service
    Contributor

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

  2. jakobbotsch commented on Feb 4, 2026

    @jakobbotsch
    Member

    Is the

    Fatal error. Invalid Program: attempted to call a UnmanagedCallersOnly method from managed code.

    in the log unrelated?

  3. rcj1 commented on Feb 4, 2026

    @rcj1
    ContributorAuthor

    No; what happens is when we return from Foo2 into Foo1, and attempt to run the resumption of Foo1 (which should be the catch handler because Foo2 throws an exception in its finally), the ResumeInfo contains bad addresses (not sure exactly what is in there, but it looks like some flags on the high bits). We set a watchpoint on the second Continuation created for Foo1, and see that the bad data is written shortly before a call to CaptureContinuationContext, and after some adrp arithmetic. The calling of a bad address in DispatchContinuations then surfaces as the UnmanagedCallersOnly error.

  4. jakobbotsch commented on Feb 5, 2026

    @jakobbotsch
    Member

    Interestingly only the second adrp/add pair is corrupted in the function in the executable. I'm guessing this is some object writer bug. I can reproduce the issue locally in the object file produced by ILC: only the second adrp/add pair looks wrong there too.

  5. jakobbotsch commented on Feb 5, 2026

    @jakobbotsch
    Member

    This fixes the issue:

    diff --git a/src/coreclr/tools/Common/Compiler/ObjectWriter/MachObjectWriter.cs b/src/coreclr/tools/Common/Compiler/ObjectWriter/MachObjectWriter.cs
    index 659c48acda2..f4aac9b81be 100644
    --- a/src/coreclr/tools/Common/Compiler/ObjectWriter/MachObjectWriter.cs
    +++ b/src/coreclr/tools/Common/Compiler/ObjectWriter/MachObjectWriter.cs
    @@ -460,6 +460,11 @@ private protected override void EmitSymbolRangeDefinition(Utf8String rangeNodeNa
                     case IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A:
                     case IMAGE_REL_BASED_ARM64_PAGEOFFSET_12L:
                         // Addend is handled through ARM64_RELOC_ADDEND
    +                    fixed (byte* pData = data)
    +                    {
    +                        addend += Relocation.ReadValue(relocType, pData);
    +                        Relocation.WriteValue(relocType, pData, 0);
    +                    }
                         break;
     
                     case IMAGE_REL_BASED_RELPTR32:

    It is the equivalent of this code that I found in LLVM:

    https://github.com/llvm/llvm-project/blob/3a084241248efd7d5259183cffae1d5b7057a54c/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp#L355-L382

    @filipnavara does this look right?

  6. filipnavara commented on Feb 5, 2026

    @filipnavara
    Member

    @filipnavara does this look right?

    At first glance it does.

    (I will have a second look tomorrow when I get back to my machine; already OOF today)

  7. self-assigned this
    on Feb 5, 2026
  8. removed
    untriagedNew issue has not been triaged by the area owner
    on Feb 5, 2026
  9. added this to the 11.0.0 milestone on Feb 5, 2026
  10. jakobbotsch commented on Feb 5, 2026

    @jakobbotsch
    Member

    It looks like we are not running runtime tests for osx-arm64 in nativeaot-outerloop, otherwise I expect we would have seen the normal async tests failing in #123433.

  11. added a commit that references this issue on Feb 10, 2026
    c4a5583
  12. added a commit that references this issue on Mar 2, 2026
    5b6bc5f
  13. locked and limited conversation to collaborators on Mar 13, 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

  • Status
    No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions