Skip to content
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

HeapDump actuator produces invalid gcdump file #1399

Open
bart-vmware opened this issue Oct 31, 2024 · 1 comment
Open

HeapDump actuator produces invalid gcdump file #1399

bart-vmware opened this issue Oct 31, 2024 · 1 comment
Labels
Component/Management Issues related to Steeltoe Management (actuators) ReleaseLine/4.x Identified as a feature/fix for the 4.x release line Status/needs-investigation Tickets needs more investigation Type/bug Something isn't working

Comments

@bart-vmware
Copy link
Member

Describe the bug

A gcdump downloaded from /actuator/heapdump can't be opened in PerfView or Visual Studio.

To capture a gcdump, use the following configuration:

{
  "Management": {
    "Endpoints": {
      "HeapDump": {
        "HeapDumpType": "gcdump"
      }
    }
  }
}

Error in PerfView:
image

Error in Visual Studio:
image

The Steeltoe documentation doesn't list gcdump as a possible dump type. However, Steeltoe v4 ignores the configured dump type on macOS and always takes a gcdump.

I was able to hack together the following code that produces a gcdump file that can be opened in PerfView, but not in Visual Studio. It requires an assembly reference to PerfView.exe, downloaded from https://github.com/microsoft/perfview/releases, and a NuGet reference to Microsoft.Diagnostics.Tracing.TraceEvent v3.1.16. It also requires elevated permissions to run, which I haven't looked into any further.

using PerfView;

const string gcDumpFileName = "C:\\Source\\dotnet-gcdump.gcdump";

App.CommandLineArgs = new CommandLineArgs { NoGui = true };
App.CommandProcessor = new CommandProcessor { LogFile = TextWriter.Null };

int processId = Environment.ProcessId;
PerfView.HeapDumper.DumpGCHeap(processId, gcDumpFileName, TextWriter.Null);

The code in Steeltoe to capture heap dumps (including gcdumps) relies on a very old copy of sources from PerfView. The CLR internals may have changed since then. A different approach could be to rely on dotnet-gcdump, which interestingly states the following:

image

Alternatively, we could drop support for capturing a gcdump entirely. The 3x Steeltoe source at https://github.com/SteeltoeOSS/Steeltoe/blob/release/3.2/src/Management/src/EndpointBase/HeapDump/HeapDumper.cs#L39 shows that a gcdump was taken only on .NET Core 3.x, or when explicitly configured. The 3x documentation states the following:

image

So it might be that gcdump support is just a left-over legacy feature from a time when it wasn't possible to capture a full dump.

@TimHess Do you have additional context on what happened and what Steeltoe should support?

@bart-vmware bart-vmware added Type/bug Something isn't working ReleaseLine/4.x Identified as a feature/fix for the 4.x release line Component/Management Issues related to Steeltoe Management (actuators) Status/needs-investigation Tickets needs more investigation labels Oct 31, 2024
@bart-vmware
Copy link
Member Author

Here's some background on the different dump types. Heap dumps aren't OS-portable, while (modern-style) gcdumps are.
https://devblogs.microsoft.com/dotnet/collecting-and-analyzing-memory-dumps/

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 Status/needs-investigation Tickets needs more investigation Type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant