Skip to content

Stack traces with async variants #122547

Open

Description

@MichalStrehovsky

The stack trace metadata would likely only have information about the thunk, not about the the calling method.

So doing DiagnosticMethodInfo.Create(new StackFrame()) in a runtime async method will likely return no information. We need to swap IsAsyncCall bodies for thunks when emitting stack trace information.

Also figure out what CoreCLR does for new StackFrame(1) (i.e. asking for the thunk).

From @davidwr This is also an issue for the coreclr interpreter, as it needs a helper function, which is defined in C#, and there is no way to disable that either.

Activity

  1. added this to the 11.0.0 milestone on Dec 15, 2025
  2. dotnet-policy-service commented on Dec 15, 2025

    @dotnet-policy-service
    Contributor

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

  3. MihuBot commented on Dec 15, 2025

    @MihuBot

    I'm a bot. Here is a possible related and/or duplicate issue (I may be wrong):

  4. VSadov commented on Dec 15, 2025

    @VSadov
    Member

    Also figure out what CoreCLR does for new StackFrame(1) (i.e. asking for the thunk).

    Seems like CoreCLR skips thunks. (skips resume stubs too). #122517 (comment)

  5. self-assigned this
    on Dec 24, 2025
  6. davidwrighton commented on Jan 6, 2026

    @davidwrighton
    Member

    @VSadov This is also an issue for the coreclr interpreter, as it needs a helper function, which is defined in C#, and there is no way to disable that either. I don't think that this test is a good idea. We can fairly easily remove the thunks from the Exception ToString, etc, by using [StackTraceHidden], and I'll do that, but the StackFrame api doesn't have that flexibility.

  7. jkotas commented on Feb 8, 2026

    @jkotas
    Member

    Fixed by #122722

  8. locked and limited conversation to collaborators on Mar 10, 2026
  9. MichalStrehovsky commented on Mar 11, 2026

    @MichalStrehovsky
    MemberAuthor

    ActiveIssue wasn't removed from the test and the test is still failing: #125423. Reopening.

  10. unlocked this conversation on Mar 11, 2026
  11. MichalStrehovsky commented on Mar 11, 2026

    @MichalStrehovsky
    MemberAuthor
    System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.)
     ---> System.NullReferenceException: Object reference not set to an instance of an object.
       at Async2Reflection.FromStackDMIAsync(Int32)
       --- End of inner exception stack trace ---
       at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean)
       at System.Threading.Tasks.Task`1.GetResultCore(Boolean)
       at Async2Reflection.FromStackDMI(Int32)
    
  12. added
    disabled-testThe test is disabled in source code against the issue
    on Mar 12, 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