Skip to content

functional tests: diagnostics for flaky CheckoutCleansUpTombstones#1955

Closed
tyrielv wants to merge 10 commits intomicrosoft:masterfrom
tyrielv:tyrielv/fix-flaky-tombstone
Closed

functional tests: diagnostics for flaky CheckoutCleansUpTombstones#1955
tyrielv wants to merge 10 commits intomicrosoft:masterfrom
tyrielv:tyrielv/fix-flaky-tombstone

Conversation

@tyrielv
Copy link
Copy Markdown
Contributor

@tyrielv tyrielv commented May 1, 2026

Problem

\WindowsTombstoneTests.CheckoutCleansUpTombstones\ fails intermittently on arm64 CI (slice 9, Debug config). The failure manifests as a mount failure (\GVFS did not mount) at line 46 after the test modifies \ModifiedPaths.dat\ while GVFS is unmounted.

Failed run: https://github.com/microsoft/VFSForGit/actions/runs/25186133967
ADO work item: AB#62098958
Parent deliverable: AB#61580834

Hypothesis

The test calls \UnmountGVFS()\ then immediately reads/writes \ModifiedPaths.dat. The unmount command may return before the GVFS process fully releases file locks, causing the \ReadAllText/\WriteAllText\ to either fail with \IOException\ or silently corrupt the file, which then prevents the subsequent mount from succeeding.

Changes

Diagnostic logging (\WindowsTombstoneTests.cs)

  • Timing for unmount/mount operations
  • File metadata (existence, size, timestamps) before file access
  • Content verification after write (read-back check)
  • Retry with 500ms backoff for file I/O (up to 10 attempts) to handle transient locks
  • On mount failure: dump ModifiedPaths content, list GVFS log files, tail latest mount log
  • Uses \TryMountGVFS\ with explicit output capture instead of hard-assert \MountGVFS\

CI restriction (\ unctional-tests.yaml)

  • Matrix restricted to \�rm64 / Debug / slice 9\ to focus runner time on reproducing the failure
  • Must revert before merge

Next steps

Once diagnostics confirm the root cause:

  1. Add proper file-lock wait after unmount (or retry in \MountGVFS)
  2. Restore full CI matrix
  3. Merge fix

tyrielv added 10 commits April 29, 2026 16:13
Retarget from net471 to net10.0-windows10.0.17763.0 across all managed
projects. Enable NativeAOT self-contained deployment, eliminating the
.NET runtime dependency.

Build infrastructure:
- global.json: pin SDK 10.0.203
- Directory.Build.props: centralized TFM, SelfContained, PublishAot,
  OptimizationPreference=Speed
- Directory.Build.targets: AOT build targets; opt out test projects and
  GVFS.MSBuild (netstandard2.0) from AOT
- Build.bat: 3-step build (dotnet restore, VS MSBuild for C++, dotnet
  publish for managed AOT binaries)
- publish-aot.ps1: standalone script for local AOT publish testing
  (CI uses Build.bat; this script is for dev iteration)
- Update output paths in all scripts (net471 -> net10.0-.../publish)
- Update CI to .NET 10 SDK and windows-2025 runner
- Update installer MinVersion to 10.0.17763

Package updates:
- Microsoft.Windows.ProjFS 1.1 -> 2.1.0: pure C# P/Invoke replacing
  C++/CLI interop, required for NativeAOT compatibility
- Microsoft.Data.Sqlite 2.2.4 -> 9.0.4, Microsoft.Build.* 16 -> 17.12.6
- Add System.Diagnostics.EventLog, System.IO.Pipes.AccessControl:
  previously included in .NET Framework, now separate packages
- Remove GVFS.ProjFS (ProjFS is now a Windows OS feature)

Unit test fixture updates for new ProjFS managed API surface.

Output: ~20 MB native GVFS.exe, 36.7 MB installer (vs 107 MB with
full self-contained runtime)

Assisted-by: Claude Opus 4.6
Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
Assembly.Location returns empty string under NativeAOT since there is no
managed assembly on disk. Assembly.GetName().Version returns null.

- ProcessHelper: use Environment.ProcessPath with null guard (can be null
  in certain hosting scenarios), fall back to AppContext.BaseDirectory
- HooksInstaller: same Environment.ProcessPath pattern with null guard
- GVFSEnlistment: AppDomain.CurrentDomain.FriendlyName replaces
  Assembly.GetEntryAssembly().GetName() for process name
- JsonTracer/PrettyConsoleEventListener: same pattern for version string

Assisted-by: Claude Opus 4.6
Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
NamedPipeServerStream (WindowsPlatform.cs):
  ACL-accepting constructor removed from .NET Core; use
  NamedPipeServerStreamAcl.Create extension method.

Directory ACL APIs (WindowsFileSystem.cs, GVFSService.Windows.cs):
  Static Directory.GetAccessControl/SetAccessControl and
  Directory.CreateDirectory(path, security) removed from .NET Core;
  replaced with DirectoryInfo instance methods and
  DirectorySecurity.CreateDirectory extension.

Uri escaping (CloneVerb.cs, GVFSVerb.cs, OrgInfoApiClient.cs):
  Uri.EscapeUriString obsoleted in .NET 10 (does not escape '#', '?');
  use Uri.EscapeDataString. HttpUtility.UrlEncode (System.Web) replaced
  with WebUtility.UrlEncode (System.Net).

UseShellExecute (WindowsPlatform.cs, InProcessMount.cs):
  .NET Framework defaults UseShellExecute=true (ShellExecuteEx, no handle
  inheritance). .NET 10 defaults to false (CreateProcess, handles inherited).
  Without this, GVFS.Mount.exe inherits the caller's stdout pipe handle,
  causing callers that read to EOF to block indefinitely.

Truncated loose object detection (GitRepo.cs):
  .NET 10 DeflateStream silently returns partial data on truncated zlib
  instead of throwing InvalidDataException. CountingStream wrapper compares
  actual bytes read to header-declared size to detect corruption.

Assisted-by: Claude Opus 4.6
Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
System.Management requires COM interop which is incompatible with
NativeAOT. Replace WMI queries (MSFT_Volume, MSFT_Partition, MSFT_Disk,
MSFT_PhysicalDisk) with direct kernel32 DeviceIoControl calls using
IOCTL_STORAGE_QUERY_PROPERTY and IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
for disk telemetry collection.

Assisted-by: Claude Opus 4.6
Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
ProjFS managed API v2.1.0 uses Marshal.PtrToStringUni which returns null
for IntPtr.Zero (kernel operations with PID 0). The old C++/CLI wrapper
returned String.Empty. Null-coalesce to match old behavior in all three
callback sites (OnPlaceholderFileCreated, OnPlaceholderFolderCreated,
OnPlaceholderFileHydrated); ConcurrentDictionary does not accept null keys.

Assisted-by: Claude Opus 4.6
Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
Replace HttpClientHandler with SocketsHttpHandler for explicit connection
pool lifecycle management: configurable MaxConnectionsPerServer (2x CPU
count), PooledConnectionLifetime, and PooledConnectionIdleTimeout. Remove
UseDefaultCredentials (not supported on SocketsHttpHandler) and
ServicePointManager usage (.NET Framework only).

GitSsl: X509Certificate2(byte[]) constructor obsoleted; use
X509CertificateLoader.LoadCertificate.

GitAuthentication: adapt credential flow for new HTTP handler.

Assisted-by: Claude Opus 4.6
Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
NativeAOT cannot use runtime reflection for JSON serialization.
GVFSJsonContext provides source-generated System.Text.Json serializers
for 25+ types used in named pipe messages and configuration.

GVFSJsonOptions chains source-gen (primary) with reflection fallback
for types not yet in the context, allowing incremental migration.

NamedPipeMessages: add parameterless constructors required by the
source generator's deserialization codegen.

Assisted-by: Claude Opus 4.6
Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
.NET 10's FileInfo property setters no longer open write handles that
trigger ProjFS placeholder hydration. Adapt tests that relied on this.

BasicFileSystemTests: replace ExpandedFileAttributesAreUpdated with two
focused tests:
- PlaceholderMetadataSurvivesHydration: sets timestamps + Hidden on a
  placeholder, verifies they took effect, hydrates via read+write, and
  asserts CreationTime and Hidden survived the conversion.
- HydratedFileTimestampsAndAttributesAreUpdated: hydrates first, then
  sets all properties and verifies they stick.

GitCommandsTests: ChangeTimestampAndDiff now explicitly hydrates via
read+write before adjusting timestamps, since File.SetLastWriteTime
no longer triggers ProjFS hydration.

GVFSProcess: add 5-minute timeout per gvfs process invocation to
prevent CI hangs. Stream stdout/stderr for real-time CI output.

functional-tests.yaml: reduce mount sleep from 500ms to 100ms,
add timeout-minutes and --workers=1 for sequential execution.

Assisted-by: Claude Opus 4.6
Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
Add diagnostic logging and retry logic to WindowsTombstoneTests.CheckoutCleansUpTombstones
to investigate intermittent mount failure on arm64 CI (slice 9, Debug).

The test modifies ModifiedPaths.dat immediately after unmount. Hypothesis:
GVFS process hasn't fully released file locks when unmount returns,
causing silent file corruption that makes the subsequent mount fail.

Diagnostics added:
- Timing for unmount/mount operations
- File existence, size, and content verification around ModifiedPaths.dat
- Retry with backoff for ReadAllText/WriteAllText (up to 10 attempts)
- GVFS mount log tail dump on mount failure
- TryMountGVFS with explicit output capture instead of hard assert

CI matrix restricted to arm64 Debug slice 9 to focus runner time on
reproducing the failure.

Assisted-by: Claude Opus 4.6
Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
Add 'run' matrix dimension (1-5) so five parallel runners each
execute the same slice 9 tests. Updated FT_MATRIX_NAME to include
run number to avoid artifact name collisions.

Assisted-by: Claude Opus 4.6
Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
@tyrielv
Copy link
Copy Markdown
Contributor Author

tyrielv commented May 1, 2026

Root cause found: stdout truncation in WaitForExit(timeout). Fix applied to net10-pr (#1953) instead.

@tyrielv tyrielv closed this May 1, 2026
@tyrielv tyrielv deleted the tyrielv/fix-flaky-tombstone branch May 1, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant