Skip to content

Memory dump fixes/enhancements#1517

Merged
bart-vmware merged 6 commits into
mainfrom
replace-gcdump
May 23, 2025
Merged

Memory dump fixes/enhancements#1517
bart-vmware merged 6 commits into
mainfrom
replace-gcdump

Conversation

@bart-vmware
Copy link
Copy Markdown
Member

@bart-vmware bart-vmware commented May 16, 2025

Description

heapdumps endpoint

This PR replaces the outdated copy from https://github.com/dotnet/diagnostics/blob/v9.0.621003/src/Tools/dotnet-gcdump (types such as MemoryGraph) with a NuGet reference to the dotnet-gcdump global tool. Steeltoe uses logic similar to https://github.com/dotnet/diagnostics/blob/v9.0.621003/src/Tools/dotnet-gcdump/CommandLine/CollectCommandHandler.cs.

For the other dump types, Steeltoe uses logic similar to https://github.com/dotnet/diagnostics/blob/v9.0.621003/src/Tools/dotnet-dump/Dumper.cs, with one exception: it doesn't use the native Windows API to collect a dump, because that doesn't support all dump types.

With the changes above, all dump types are supported on all platforms (Windows, Linux, macOS). We can't test all dump types on macOS in cibuild, because they trigger an OS-level popup that hangs everything.

The filename of the resulting zip file now includes the type of dump.

In options, HeapDumpType was changed from string to enum, and its members are documented. This change doesn't break existing appsettings.json files.

It's unclear why Visual Studio is unable to open .gcdump files, despite being documented otherwise. But the gcdump files from all platforms can be opened in PerfView and dotnet-heapview. A bug in dotnet-gcdump currently prevents it from loading a dump from disk.

For non-gcdumps, the binaries differ per platform.

  • Visual Studio can open all dump types taken on Windows, and most types taken on Linux. The same applies to JetBrains dotMemory when running on Windows (opening an existing dump when running on macOS isn't available).
  • Dumps taken on macOS can only be analyzed on macOS, using SOS commands in the dotnet-dump global tool.

threaddump endpoint

This PR syncs up the code with its origin (we can't reference the NuGet tool because its types are inaccessible), fixes several bugs and cleans up the JSON response.

  • Backport changes from https://github.com/dotnet/diagnostics/tree/v9.0.621003/src/Tools/dotnet-stack
    • Fix crash in thread ID detection
    • Fix spelling in comments
  • Replace custom code for determining the line number by calling the provided API
  • Changes in output format:
    • Split className value into added moduleName (assembly) and className (type name with namespace), based on Spring docs
    • Bugfix: only the first part of an assembly name was returned (ie: "Steeltoe" instead of "Steeltoe.Management.Endpoint")
    • Add lineColumn in output, next to existing lineNumber
    • Hide fields that are unavailable in .NET, such as thread owner, block count, etc.
  • Improved handling of cancellation/timeout
  • Add logging of captured output at Trace level
  • More efficient stack frame parsing by using ReadOnlySpan<char> instead of strings, fix offset bugs

General

  • Replace usage of CancellationToken.None with TestContext.Current.CancellationToken in other tests
  • Remove unused version property in versions.props
  • Refactor tests for dumps, which serves as a proposal for Review Management tests  #1028 (testing configuration changes not yet included)

Closes #1399.

Quality checklist

  • Your code complies with our Coding Style.
  • You've updated unit and/or integration tests for your change, where applicable.
  • You've updated documentation for your change, where applicable.
    If your change affects other repositories, such as Documentation, Samples and/or MainSite, add linked PRs here.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.
  • You've added required license files and/or file headers (explaining where the code came from with proper attribution), where code is copied from StackOverflow, a blog, or OSS.

@bart-vmware bart-vmware force-pushed the replace-gcdump branch 10 times, most recently from 9523915 to 9a7e13a Compare May 20, 2025 12:47
@bart-vmware bart-vmware changed the title Heapdump enhancements Memory dump fixes/enhancements May 22, 2025
@bart-vmware bart-vmware marked this pull request as ready for review May 22, 2025 15:31
@bart-vmware bart-vmware requested a review from TimHess May 22, 2025 15:31
Comment thread src/Management/src/Endpoint/Actuators/HeapDump/HeapDumper.cs Outdated
Comment thread src/Management/src/Endpoint/Steeltoe.Management.Endpoint.csproj
Comment thread azure-pipelines.yml
@bart-vmware bart-vmware requested a review from TimHess May 23, 2025 05:35
Copy link
Copy Markdown
Member

@TimHess TimHess left a comment

Choose a reason for hiding this comment

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

LGTM

@bart-vmware bart-vmware merged commit a2b3556 into main May 23, 2025
22 checks passed
@bart-vmware bart-vmware deleted the replace-gcdump branch May 23, 2025 14:04
@bart-vmware bart-vmware added Component/Management Issues related to Steeltoe Management (actuators) ReleaseLine/4.x Identified as a feature/fix for the 4.x release line labels May 23, 2025
@bart-vmware bart-vmware added this to the 4.0.0-rc1 milestone May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component/Management Issues related to Steeltoe Management (actuators) ReleaseLine/4.x Identified as a feature/fix for the 4.x release line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HeapDump actuator produces invalid gcdump file

2 participants