-
Notifications
You must be signed in to change notification settings - Fork 5.5k
GCRoot: Report GCFrame and in-flight exception objects #129145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
leculver
wants to merge
4
commits into
dotnet:main
Choose a base branch
from
leculver:cdac-exinfo-stack-roots
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+360
−5
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a9578fc
[cdac] Report GCFrame and in-flight exception objects as stack refere…
leculver 0d824ab
Address PR review: pass GCFrame flags through, guard new root reporti…
leculver 3665c47
Address second PR review round: SP, DataType placement, docs, test guard
leculver 0786e5a
cdac: final cleanup and hardening pass for stack-reference reporting
leculver File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Data/GCFrame.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Microsoft.Diagnostics.DataContractReader.Data; | ||
|
|
||
| [CdacType(nameof(DataType.GCFrame))] | ||
| internal sealed partial class GCFrame : IData<GCFrame> | ||
| { | ||
| [Field] public TargetPointer Next { get; } | ||
| [Field] public TargetPointer ObjRefs { get; } | ||
| [Field] public uint NumObjRefs { get; } | ||
| [Field] public uint GCFlags { get; } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/native/managed/cdac/tests/DumpTests/Debuggees/GCProtect/GCProtect.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <DumpTypes>Full</DumpTypes> | ||
| </PropertyGroup> | ||
| </Project> |
45 changes: 45 additions & 0 deletions
45
src/native/managed/cdac/tests/DumpTests/Debuggees/GCProtect/Program.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Reflection; | ||
| using System.Runtime.CompilerServices; | ||
|
|
||
| /// <summary> | ||
| /// Debuggee for cDAC dump tests — exercises GCFrame (GCPROTECT) root reporting. | ||
| /// Triggers AppDomain.AssemblyResolve by loading a missing assembly. The native | ||
| /// AppDomain::RaiseAssemblyResolveEvent invokes the managed handler while holding a | ||
| /// GCPROTECT frame over the requesting Assembly reference. The handler FailFasts so the | ||
| /// dump captures the thread with that GCFrame still live. The GC reports the GCFrame's protected | ||
| /// objects via GCFrame::GcScanRoots; the test verifies WalkStackReferences reports them too. | ||
| /// </summary> | ||
| internal static class Program | ||
| { | ||
| private static void Main() | ||
| { | ||
| AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve; | ||
| TriggerResolve(); | ||
| Environment.FailFast("cDAC dump test: GCProtect debuggee did not hit the resolve handler"); | ||
| } | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| private static void TriggerResolve() | ||
| { | ||
| try | ||
| { | ||
| Assembly.Load("cDAC_Missing_Assembly_GCFrameMarker, Version=9.9.9.9, Culture=neutral, PublicKeyToken=null"); | ||
| } | ||
| catch | ||
| { | ||
| // Resolution ultimately fails; the crash happens inside the handler below first. | ||
| } | ||
| } | ||
|
|
||
| private static Assembly? OnAssemblyResolve(object? sender, ResolveEventArgs args) | ||
| { | ||
| // Runs inside AppDomain::RaiseAssemblyResolveEvent's GCPROTECT(gc) scope, so the | ||
| // requesting Assembly reference is held only by that native GCFrame at this point. | ||
| Environment.FailFast("cDAC dump test: GCProtect debuggee intentional crash"); | ||
| return null; | ||
| } | ||
| } |
5 changes: 5 additions & 0 deletions
5
src/native/managed/cdac/tests/DumpTests/Debuggees/NestedException/NestedException.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <DumpTypes>Full</DumpTypes> | ||
| </PropertyGroup> | ||
| </Project> |
47 changes: 47 additions & 0 deletions
47
src/native/managed/cdac/tests/DumpTests/Debuggees/NestedException/Program.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.IO; | ||
| using System.Runtime.CompilerServices; | ||
|
|
||
| /// <summary> | ||
| /// Debuggee for cDAC dump tests — exercises in-flight exception root reporting. | ||
| /// Builds a nested exception chain: a superseded <see cref="FileNotFoundException"/> | ||
| /// (kept alive on the thread's ExInfo chain as the previous nested tracker) plus the | ||
| /// current <see cref="InvalidOperationException"/>, then crashes via FailFast while both | ||
| /// are still in flight. The GC reports these via gcenv.ee.cpp ScanStackRoots; the test verifies | ||
| /// WalkStackReferences reports them as stack references. | ||
| /// </summary> | ||
| internal static class Program | ||
| { | ||
| private static void Main() | ||
| { | ||
| try | ||
| { | ||
| ThrowNested(); | ||
| } | ||
| catch (Exception current) | ||
| { | ||
| // 'current' is the InvalidOperationException; the superseded | ||
| // FileNotFoundException is still held on the thread's ExInfo chain. | ||
| GC.KeepAlive(current); | ||
| Environment.FailFast("cDAC dump test: NestedException debuggee intentional crash"); | ||
| } | ||
| } | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| private static void ThrowNested() | ||
| { | ||
| try | ||
| { | ||
| throw new FileNotFoundException("cDAC-NestedException-inner"); | ||
| } | ||
| catch (FileNotFoundException inner) | ||
| { | ||
| // Throwing while handling 'inner' supersedes its ExInfo (kept as the | ||
| // previous nested tracker) and starts a new tracker for the outer exception. | ||
| throw new InvalidOperationException("cDAC-NestedException-outer", inner); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.