Skip to content

Add option to collect gcdump (MTPv2) #7126

Description

Summary

When a hang or crash occurs when running tests in the C/I environment on macOS, we are unable to analyze the dump file because none of our team members owns a Mac. It would be handy to be able to collect a dump in GCDump format, which can be loaded cross-platform.

Proposed Feature

The currently supported dump types for the --crashdump-type and --hangdump-type parameters are, according to https://learn.microsoft.com/en-us/dotnet/core/testing/microsoft-testing-platform-extensions-diagnostics: Mini, Heap, Triage, Full.

An additional option should be provided to collect a GC (Garbage Collector) dump, similar to how https://learn.microsoft.com/en-us/dotnet/core/diagnostics/dotnet-gcdump works.

Activity

  1. added
    area/mtp
    and removed
    needs/triage
    on Dec 15, 2025
  2. nohwnd commented on Dec 15, 2025

    @nohwnd
    Member

    I am looking for package that could do this without hacks, like we have Microsoft.Diagnostics.NETCore.Client for the normal dump.

  3. nohwnd commented on Dec 16, 2025

    @nohwnd
    Member

    I asked internally and there is no pre-made package for this, just the dotnet gc-dump tool, and that is 5MB package that we probably don't want to restore for all projects.

  4. Youssef1313 commented on Jan 8, 2026

    @Youssef1313
    Member

    I'm not sure if gcdump will be able to help rooting down a crash/hang actually. So it's hard to see if this is something of value that we want to do or not.

    When a hang or crash occurs when running tests in the C/I environment on macOS, we are unable to analyze the dump file because none of our team members owns a Mac. It would be handy to be able to collect a dump in GCDump format, which can be loaded cross-platform.

    At least for crashes, I think #7168 might be a better option here. I'm not sure if it's possible to have something similar for hangs or not.

  5. Evangelink commented on May 28, 2026

    @Evangelink
    Member

    Thanks for the suggestion, Bart Koelman (@bart-vmware)! After looking into this, I'd like to suggest a different approach that should address your core pain point.

    Since MTP 2.3 we will ship a --crash-report option on the CrashDump extension (added via #7168 / #8191). It uses .NET's DOTNET_EnableCrashReportOnly to produce a small *.crashreport.json file alongside (or instead of) the binary dump, containing the managed thread stacks of the crashing process. It's plain JSON, fully cross‑platform, and tiny — so a macOS CI crash can be triaged from Windows or Linux without anyone owning a Mac.

    A few notes on the gcdump‑as‑dump‑type idea:

    • For crashes specifically, gcdump isn't really feasible. Unlike minidump/heap/full, the runtime has no DOTNET_* switch to emit a gcdump when a process crashes. Gcdump is collected via EventPipe against a live process, so by the time the test host has crashed it's too late to capture anything meaningful. We'd have to continuously snapshot the heap on a side thread/process during the run, which is a structural change with a perf cost.
    • For hangs it's technically possible, but the value is narrow: a gcdump contains the managed object graph only — no thread stacks, no lock state, no native frames — so it can't diagnose the common hang causes (deadlocks, infinite loops, blocking P/Invoke, async deadlocks). It only really helps for hangs caused by heap bloat / GC thrashing.
    • It would also pull in Microsoft.Diagnostics.Tracing.TraceEvent (~5 MB+), which is the same concern Jakub Jareš (@nohwnd) raised above.

    Given that, for your CI scenario I'd recommend trying --crash-report (optionally with --crashdump-type Mini for a small binary dump too), and reserving dotnet-gcdump as an out‑of‑band tool for the rarer "I suspect a managed memory leak" case. If you try the crash report and it doesn't cover what you need, let us know what's missing — we'd rather invest in a richer cross‑platform hang/crash text report than in gcdump support.

    Closing this as "won't fix" for now, but happy to reopen if the crash report turns out to be insufficient for your workflow.

  6. bart-vmware commented on May 28, 2026

    @bart-vmware
    Author

    Thanks for the explanation, it sounds reasonable.

    What concerns me is the following from #8191:

    On Windows, --crash-report is rejected at command-line validation time because the .NET runtime ignores DOTNET_EnableCrashReport / DOTNET_EnableCrashReportOnly on Windows (see dotnet/runtime#80191). The error message points users to --crashdump as the alternative.

    This means we'll need different test commands per OS in GitHub Actions workflows. It would be more practical to only log an info-level message on Windows that the switch is ignored. rather than failing on it. We build/run with warnaserror, so chnging to a warning wouldn't help either.

  7. Evangelink commented on May 28, 2026

    @Evangelink
    Member

    This means we'll need different test commands per OS in GitHub Actions workflows. It would be more practical to only log an info-level message on Windows that the switch is ignored. rather than failing on it. We build/run with warnaserror, so chnging to a warning wouldn't help either.

    I'll try to think about what I can do. For MTP, we are trying to be "strict" because we have had too many issues and support on VSTest that's coming from having soft messages (sadly not everyone is observing their CI).

  8. bart-vmware commented on May 28, 2026

    @bart-vmware
    Author

    How about emitting the error, but with a message that explains to set an environment variable to suppress it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/mtp

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions