Skip to content

Runtime-async Exception.ToString() - #122722

Merged
hoyosjs merged 101 commits into
dotnet:mainfrom
rcj1:dev/rachel/asyncv2-exception-tostring
Feb 5, 2026
Merged

Runtime-async Exception.ToString()#122722
hoyosjs merged 101 commits into
dotnet:mainfrom
rcj1:dev/rachel/asyncv2-exception-tostring

Conversation

@rcj1

@rcj1rcj1 commented Dec 24, 2025

Copy link
Copy Markdown
Contributor

This PR implements exception stack trace collection in runtime-async stacks for both coreclr and nativeAOT.

  • Augmenting stack unwinding logic in AsyncHelpers.CoreCLR.cs to append frames from runtime-async async-await chain to exception stacktrace using DiagnosticIP of Continuation.

  • Implements ThrowExact helper to throw exception that has been stored in Continuation, while keeping its existing stack trace intact. Accomplished by creating throw helpers that set ExKind.RethrowFlag. Would be open to rename "RethrowFlag" and companions to "NoEraseFlag" or something similar, or leave as is.

  • ILC changes: Ensuring that stack trace records are emitted for runtime-async methods, and hidden for resumption stubs.

  • Testing: Added tests for line/method/document correctness including v1-v2 chaining.

@dotnet/ilc-contrib

jakobbotschand others added 30 commits October 1, 2025 14:54
- Add new JIT-EE API to report back debug information about the
generated state machine and continuations
- Refactor debug info storage on VM side to be more easily extensible.
The new format has either a thin or fat header. The fat header is used
when we have either uninstrumented bounds, patchpoint info, rich debug
info or async debug info, and stores the blob sizes of all of those
components in addition to the bounds and vars.
- Add new async debug information to the storage on the VM side
- Set get target method desc for async resumption stubs, to be used for
mapping from continuations back to the async IL function that it will
resume.
CopilotAI review requested due to automatic review settings February 4, 2026 06:46

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 41 out of 41 changed files in this pull request and generated 5 comments.

Comment threadsrc/coreclr/vm/exkind.h
Comment threadsrc/coreclr/vm/common.h
Comment threadsrc/libraries/System.Diagnostics.StackTrace/tests/StackTraceTests.cs Outdated
@rcj1

rcj1 commented Feb 4, 2026

Copy link
Copy Markdown
ContributorAuthor

/azp run runtime-nativeaot-outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

CopilotAI review requested due to automatic review settings February 4, 2026 21:04
@rcj1

rcj1 commented Feb 4, 2026

Copy link
Copy Markdown
ContributorAuthor

/azp run runtime-nativeaot-outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@rcj1

rcj1 commented Feb 4, 2026

Copy link
Copy Markdown
ContributorAuthor

/azp run runtime-nativeaot-outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 41 out of 41 changed files in this pull request and generated 1 comment.

Comment threadsrc/coreclr/vm/common.h
@rcj1

rcj1 commented Feb 5, 2026

Copy link
Copy Markdown
ContributorAuthor

/ba-g unrelated failures

@steveisok
steveisok enabled auto-merge (squash) February 5, 2026 03:30
@hoyosjs
hoyosjs disabled auto-merge February 5, 2026 04:22
@hoyosjs
hoyosjs merged commit 7fa306e into dotnet:mainFeb 5, 2026
175 of 179 checks passed
lewing pushed a commit to lewing/runtime that referenced this pull request Feb 9, 2026
…3831)
Testing on dotnet#122722 revealed some issues with dotnet#123333 so I am fixing
these here.
After dotnet#123333 there remain two error cases:
1. Our IL offset is greater than the previously found offset, but lower
than the max found offset. In this case, we would like to advance the
line number in accordance with the new IL offset, which was omitted
after dotnet#123333.
2. Our IL offset is greater than the highest IL offset for which there
exists a sequence point. In this case, we want to ensure we can create a
native <-> line mapping - dotnet#123333 had left these IL offsets with a
Document of null, meaning no mappings were possible.
This fixes both of these issues.
Before:
<img width="1298" height="268" alt="Screenshot 2026-01-30 192451"
src="https://github.com/user-attachments/assets/ab46947f-ea52-4530-949b-3e36bf3b3df6"
/>
<img width="1312" height="359" alt="Screenshot 2026-01-30 192408"
src="https://github.com/user-attachments/assets/b08a8f45-0af2-484a-8392-8d12c3694361"
/>
After:
<img width="1020" height="311" alt="Screenshot 2026-01-30 190332"
src="https://github.com/user-attachments/assets/ac8bca54-6466-4436-9fac-1f6f685e7bd0"
/>
<img width="1030" height="400" alt="Screenshot 2026-01-30 190613"
src="https://github.com/user-attachments/assets/321c8160-cf06-4f43-8c36-352d2bd6908a"
/>
[foo.txt](https://github.com/user-attachments/files/24984632/foo.txt)
[foo2.txt](https://github.com/user-attachments/files/24984633/foo2.txt)
[New Compressed (zipped)
Folder.zip](https://github.com/user-attachments/files/24976959/New.Compressed.zipped.Folder.zip)
---------
Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
lewing pushed a commit to lewing/runtime that referenced this pull request Feb 9, 2026
This PR implements exception stack trace collection in runtime-async
stacks for both coreclr and nativeAOT.
* Augmenting stack unwinding logic in AsyncHelpers.CoreCLR.cs to append
frames from runtime-async async-await chain to exception stacktrace
using DiagnosticIP of Continuation.
* Implements ThrowExact helper to throw exception that has been stored
in Continuation, while keeping its existing stack trace intact.
Accomplished by creating throw helpers that set ExKind.RethrowFlag.
Would be open to rename "RethrowFlag" and companions to "NoEraseFlag" or
something similar, or leave as is.
* ILC changes: Ensuring that stack trace records are emitted for
runtime-async methods, and hidden for resumption stubs.
* Testing: Added tests for line/method/document correctness including
v1-v2 chaining.
@dotnet/ilc-contrib
---------
Co-authored-by: Jakob Botsch Nielsen <jakob.botsch.nielsen@gmail.com>
Co-authored-by: Adeel <3840695+am11@users.noreply.github.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
iremyux pushed a commit to iremyux/dotnet-runtime that referenced this pull request Mar 2, 2026
…3831)
Testing on dotnet#122722 revealed some issues with dotnet#123333 so I am fixing
these here.
After dotnet#123333 there remain two error cases:
1. Our IL offset is greater than the previously found offset, but lower
than the max found offset. In this case, we would like to advance the
line number in accordance with the new IL offset, which was omitted
after dotnet#123333.
2. Our IL offset is greater than the highest IL offset for which there
exists a sequence point. In this case, we want to ensure we can create a
native <-> line mapping - dotnet#123333 had left these IL offsets with a
Document of null, meaning no mappings were possible.
This fixes both of these issues.
Before:
<img width="1298" height="268" alt="Screenshot 2026-01-30 192451"
src="https://github.com/user-attachments/assets/ab46947f-ea52-4530-949b-3e36bf3b3df6"
/>
<img width="1312" height="359" alt="Screenshot 2026-01-30 192408"
src="https://github.com/user-attachments/assets/b08a8f45-0af2-484a-8392-8d12c3694361"
/>
After:
<img width="1020" height="311" alt="Screenshot 2026-01-30 190332"
src="https://github.com/user-attachments/assets/ac8bca54-6466-4436-9fac-1f6f685e7bd0"
/>
<img width="1030" height="400" alt="Screenshot 2026-01-30 190613"
src="https://github.com/user-attachments/assets/321c8160-cf06-4f43-8c36-352d2bd6908a"
/>
[foo.txt](https://github.com/user-attachments/files/24984632/foo.txt)
[foo2.txt](https://github.com/user-attachments/files/24984633/foo2.txt)
[New Compressed (zipped)
Folder.zip](https://github.com/user-attachments/files/24976959/New.Compressed.zipped.Folder.zip)
---------
Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
iremyux pushed a commit to iremyux/dotnet-runtime that referenced this pull request Mar 2, 2026
This PR implements exception stack trace collection in runtime-async
stacks for both coreclr and nativeAOT.
* Augmenting stack unwinding logic in AsyncHelpers.CoreCLR.cs to append
frames from runtime-async async-await chain to exception stacktrace
using DiagnosticIP of Continuation.
* Implements ThrowExact helper to throw exception that has been stored
in Continuation, while keeping its existing stack trace intact.
Accomplished by creating throw helpers that set ExKind.RethrowFlag.
Would be open to rename "RethrowFlag" and companions to "NoEraseFlag" or
something similar, or leave as is.
* ILC changes: Ensuring that stack trace records are emitted for
runtime-async methods, and hidden for resumption stubs.
* Testing: Added tests for line/method/document correctness including
v1-v2 chaining.
@dotnet/ilc-contrib
---------
Co-authored-by: Jakob Botsch Nielsen <jakob.botsch.nielsen@gmail.com>
Co-authored-by: Adeel <3840695+am11@users.noreply.github.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Mar 7, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants

@rcj1@jkotas@janvorli@am11@jakobbotsch@davidwrighton@MichalStrehovsky@max-charlamb@hoyosjs