Repository navigation
[release/stable] Backport process discovery, gcdump, and trace updates - #6078
Merged
hoyosjs merged 5 commits intoSep 30, 2026
Merged
Conversation
…ocess discovery (dotnet#5904) Fixes dotnet#5903 ## Problem `DiagnosticsClient.GetProcPublishedProcesses` enumerates `/proc` to discover diagnostic-capable processes. Two best-effort per-process read helpers only caught `DirectoryNotFoundException` / `UnauthorizedAccessException`: - `GetProcessTmpDir` reads `/proc/{pid}/environ`. Kernel threads (e.g. `kthreadd` at PID 2) have no user address space, so the kernel returns `-ESRCH` and the runtime surfaces a plain `IOException` (`"No such process"`). This escaped the catch and aborted the entire enumeration, crashing `GetPublishedProcesses` on **every** Linux host, since kernel threads are always present. - `TryGetNamespacePid` reads `/proc/{pid}/status` and had the same too-narrow catch, so a process-exit race or a `hidepid`-restricted process could throw. This was introduced by dotnet#5735 (first shipped in `0.2.721401`) and is still present in the latest package. ## Fix - Broaden both catches to `IOException`, which subsumes the prior `DirectoryNotFoundException` / `FileNotFoundException` exit-race cases. - Add a `UnauthorizedAccessException` catch to `TryGetNamespacePid` (parity with `GetProcessTmpDir`). Both helpers are best-effort, so they now consistently skip an unreadable entry rather than throwing and aborting discovery. The enumeration loop is unchanged. ## Tests Adds two Linux-gated (`[ConditionalFact]`) tests in `PidIpcEndpointTests`: - `GetProcessTmpDir_KernelThread_DoesNotThrow` — finds a process whose `environ` throws `IOException` (a kernel thread) and asserts the temp-dir fallback is returned. Skips if no such process is visible (e.g. inside a container with its own PID namespace). - `TryGetNamespacePid_NonExistentPid_DoesNotThrow` — a non-existent PID returns `false` rather than throwing. --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]> (cherry picked from commit 3a91cb2) Co-authored-by: Copilot App <[email protected]> Copilot-Session: 1bf039ff-37e1-40b6-af8c-125192e61855
…t#5886) Diagnostics counterpart to dotnet/runtime#129457 for fixing dotnet#2404 This PR proposes a new CollectTracing command `CollectTracing6` that exposes a new `sessionBufferMode` configuration option to specify how an IPC Streaming EventPipe Session using buffers should handle events when buffers are full. 0 - Drop (default, pre-existing behavior) 1 - Block (non-lossy, parks producer threads until buffer space is available) Additionally, this PR introduces serializing for CollectTracing5 (non-UserEvents) and CollectTracing6, and adds a new `--non-lossy` option to `dotnet-gcdump collect` to leverage the new non-lossy mode. --------- Co-authored-by: Copilot <[email protected]> (cherry picked from commit 7e8e386) Co-authored-by: Copilot App <[email protected]> Copilot-Session: 1bf039ff-37e1-40b6-af8c-125192e61855
Fixes dotnet#6048 ## Summary - Keep EventPipe completion state local to each live collection and file conversion. - Report success only after heap graph conversion completes. - Document that the live collection log writer must support concurrent writes. - Add regression coverage for a post-GCStop logging failure returning false. ## Root cause The failure in dotnet#6048 has two parts. Steeltoe calls `EventPipeDotNetHeapDumper` directly and supplies a plain `StreamWriter`, while the method logs concurrently from the EventPipe reader and session stop tasks. That caller-provided writer is not thread-safe, which explains the torn log line and `StreamWriter.Flush` exception. The shipped CLI uses synchronized `Console.Out`, so diagnostics continues to require callers of the direct API to provide a writer that supports concurrent writes. After the logging exception, graph conversion is skipped. The previous implementation nevertheless returned the process-wide `dumpComplete` flag set when `GCStop` was observed. The caller therefore received `true` for an unconverted graph and failed with `RootIndex not set`. The process-wide flags also allowed separate or concurrent operations to affect each other. This change gives each operation its own completion state and separates GC completion from operation success. `true` is returned only after `ConvertHeapDataToGraph()` completes. Steeltoe must separately use a synchronized writer for direct in-process gcdump calls. ## Reproduction A real self-gcdump test injects a logging failure after `GCStop` and verifies that the operation returns `false` because graph conversion did not complete. The targeted test passes in Debug and Release. --------- Copilot-Session: 432587bf-ff0a-4257-ad8a-fc58a1a8c6a9 (cherry picked from commit 2a16a62) Co-authored-by: Copilot App <[email protected]> Copilot-Session: 1bf039ff-37e1-40b6-af8c-125192e61855
(cherry picked from commit 1fb4a0b) Co-authored-by: Copilot App <[email protected]> Copilot-Session: 1bf039ff-37e1-40b6-af8c-125192e61855
…dotnet#6071) Bump `record-trace` to get unwind improvements and other fixes. Newer `record-trace` versions also have a [`max-memory` option](microsoft/one-collect#291) so wire that up too. It stops collection when the memory of the collecting process, `dotnet-trace` in this case, exceeds the given limit. I'm open to suggestions on the option description. For reference, the description in record-trace is ``` Stop collecting once this process uses the specified amount of memory, in megabytes ``` Example output when the memory limit is reached: ``` root [ /src ]# ./dotnet-trace collect-linux --duration '00:00:20' --max-memory 100 No providers, profiles, ClrEvents, or PerfEvents were specified, defaulting to trace profiles 'dotnet-common' + 'cpu-sampling'. Provider Name Keywords Level Enabled By Microsoft-Windows-DotNETRuntime 0x000000100003801D Informational(4) --profile Linux Perf Events Enabled By cpu-sampling --profile Output File : /src/trace_20260910_004355.nettrace [00:00:00:01] Recording trace. Press <Enter> or <Ctrl+C> to exit... Memory limit reached. Recording stopped. Resolving symbols. Finished recording trace. Trace written to /src/trace_20260910_004355.nettrace ``` (cherry picked from commit 2e2793f) Co-authored-by: Copilot App <[email protected]> Copilot-Session: 1bf039ff-37e1-40b6-af8c-125192e61855
hoyosjs
marked this pull request as ready for review
September 30, 2026 00:32
steveisok
approved these changes
Sep 30, 2026
Member
Author
|
Preexisting mac bug in event pipeline testing - other timeout is unrelated to diagnostics. |
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Backport the Linux
/procprocess-discovery fix for #6040 and the gcdump and dotnet-trace changes needed onrelease/stable:dotnet-trace collect --buffering-mode Block.collect-linuxpreview banner.record-traceand addcollect-linux --max-memory.Non-lossy buffering requires a .NET 11+ target runtime; gcdump warns and falls back to lossy collection for older runtimes. Linux-specific behavior has not been exercised locally on Windows.