Skip to content

[MTP Diagnostic Analysis] HangDump publishes quoted dump paths as artifacts on Windows #8408

@Evangelink

Description

@Evangelink

Summary

On Windows, HangDump quotes dump paths that contain spaces before calling DiagnosticsClient.WriteDump, but then stores the quoted path in _dumpFiles and later publishes it as a FileArtifact. The artifact path therefore includes literal " characters and no longer points to the real dump file.

Evidence

  • Q:\src\testfx\src\Platform\Microsoft.Testing.Extensions.HangDump\HangDumpProcessLifetimeHandler.cs:377-380
    • if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && finalDumpFileName.Contains(' '))
    • finalDumpFileName = $"\"{finalDumpFileName}\"";
  • Q:\src\testfx\src\Platform\Microsoft.Testing.Extensions.HangDump\HangDumpProcessLifetimeHandler.cs:385-388
    • if (dumpType.HasValue)
    • diagnosticsClient.WriteDump(dumpType.Value, finalDumpFileName, logDumpGeneration: false);
    • _dumpFiles.Add(finalDumpFileName);
  • Q:\src\testfx\src\Platform\Microsoft.Testing.Extensions.HangDump\HangDumpProcessLifetimeHandler.cs:216-218
    • foreach (string dumpFile in _dumpFiles)
    • new FileArtifact(new FileInfo(dumpFile), ExtensionResources.HangDumpArtifactDisplayName, ...)
  • Q:\src\testfx\src\Platform\Microsoft.Testing.Platform\Messages\FileArtifacts.cs:19-25
    • public FileArtifact(FileInfo fileInfo, string displayName, string? description = null)
    • public FileInfo FileInfo { get; }

Why this is a real issue

This is not just cosmetic: the stored artifact path is different from the file path on disk. Windows result directories frequently contain spaces (for example under C:\Users\...), so the workaround path is likely to be hit in normal usage. Downstream artifact handling gets a FileInfo for "C:\...\dump.dmp" instead of C:\...\dump.dmp.

Suggested resolution

Keep an unquoted path for bookkeeping/artifact publication and use a separate quoted variable only for the WriteDump workaround. Add a regression test that exercises a results directory with spaces.

Related issues

  • External runtime workaround referenced in code: dotnet/diagnostics#5020

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions