Registry Mirror
Skip to content

Conversation

@christophwille

@christophwille christophwille commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

The flake

ProcessExplorerTests.Modules_Of_The_Current_Process_Include_Its_Own_Assemblies failed in the Windows Release job of #4150 (run 35439301458) with OperationCanceledException after 1m 00.9s - the test's own 60 s CancellationTokenSource, thrown from NetFrameworkProcesses.Enumerate. #4150 only changes XAML styles, the same commit passed Windows Release in the parallel push-event run, and the test passes locally in isolation (3 of 3). None of the five preceding failed Build ILSpy runs shows it, but it has since happened again on an unrelated branch: run 35527479296, Windows Debug, NetFrameworkProcessesTests.The_Explorer_Routes_A_Framework_Process_To_The_Module_Scan in ILSpy.Tests.Windows, again OperationCanceledException from NetFrameworkProcesses.Enumerate at the test's 60 s budget (1m 05s). Different test, same whole-machine scan, so every test that calls GetProcessesAsync on Windows is exposed.

Likely cause

On Windows, ProcessExplorer.GetProcessesAsync finishes with a scan for .NET Framework processes that read Process.Modules of every process on the machine to look for clr.dll. Process.Modules issues several cross-process memory reads per loaded module, so its cost depends on what the rest of the machine is doing. Measured on a 24-core desktop:

whole-machine module scan
idle 3.0 - 4.7 s (three tests pay this, 4.4 - 5.2 s each)
CPUs oversubscribed 2x by busy-loop processes 7.5 - 22 s, single suspended UWP processes (StartMenuExperienceHost, LockApp) costing 4 - 11 s each

The CI job runs dotnet test --solution ilspy.sln on a 4-core runner, so the decompiler suite - which spawns compilers and test runners continuously and saturates the cores - runs next to the UI tests. I could not observe the runner itself, so "the scan crossed 60 s under that load" is an inference from the stack trace, the exact-budget duration, and the load sensitivity measured above; the two sibling tests that do the same scan passed in the same run, which fits a load spike rather than a defect in the test.

Fix

Make the scan cheap instead of giving the test more time. Every desktop CLR publishes a named shared-memory block per process (Cor_Private_IPCBlock_v4_<pid>, the mechanism the Framework-era ICorPublish used to find managed processes). NetFrameworkProcesses.MayHostDesktopClr does that name lookup, and only candidates get the module read, which still supplies the runtime version, the architecture and the confirmation that clr.dll is loaded.

  • Only a definite ERROR_FILE_NOT_FOUND on every name rules a process out. A block that exists but is access-denied (services, other users) stays a candidate and is handled by the module read exactly as before, so the listing does not change. On the development machine the lookup marked 11 of 377 processes; the 3 that can be opened are exactly the 3 the module scan lists.
  • Probing all 377 processes took 118 ms. The three whole-machine tests drop from 4.4 - 5.2 s to under 0.2 s idle, and the previously failing one takes 1.2 s under the synthetic load above. The "Open from running process" dialog gets the same speed-up.

Tried and rejected: running the module scan through PLINQ. It is faster when idle (3.0 s -> 0.7 s) but under load several suspended processes read concurrently stalled for more than 90 s, i.e. it makes the failure mode worse.

Not verified: the pre-v4 block name (Cor_Private_IPCBlock_<pid>, CLR 2.0 / mscorwks.dll). No v2 runtime is installed on the development machine, so that name comes from the CLR's naming scheme, not from a live process. If it were wrong, .NET 2.0/3.5 processes would drop out of the listing.

Tests

Two cases added to the existing NetFrameworkProcessesTests fixture in ILSpy.Tests.Windows (Windows PowerShell 5.1 as the .NET Framework host):

  • the CoreCLR test host is ruled out by the lookup (shown red against a stub that treats every process as a candidate, which is the previous behavior),
  • the fixture's Framework host is a candidate.

The fixture's existing cases (found and described, not listed twice, managed modules only, routed through ProcessExplorer) guard against the pre-filter dropping real processes and pass unchanged.

ILSpy.Tests.Windows: 88 passed, 0 failed. ILSpy.Tests: 1287 passed, 0 failed, 4 skipped - run with the product change while three lookup cases still lived in that project; they have since moved to the Windows fixture (two of them; the third duplicated an existing case) and the project was only rebuilt, not rerun, after that.

Assisted-by: Claude:claude-fable-5-1:Claude Code

The .NET Framework half of the process listing read the module list of
every process on the machine to look for clr.dll. That read costs several
cross-process memory reads per loaded module, so its duration depends on
what else the machine is doing: about 4 s idle on a desktop, 10 to 22 s
with the CPUs oversubscribed, dominated by single suspended UWP processes
at 4 to 11 s each. On a 4-core CI runner that runs the decompiler suite
next to the UI tests it crossed the 60 s budget of a ProcessExplorerTests
case, which failed with OperationCanceledException on a commit that did
not touch this code.

Spreading the scan over the cores was tried and rejected: several
suspended processes read concurrently stalled for over 90 s under the
same load. The desktop CLR instead announces itself through a named
shared-memory block per process, so a name lookup now decides which
processes get the module read at all. Only a definite "no such object"
rules a process out; an access-denied block stays a candidate, which
keeps the listing identical. The pre-v4 block name could not be checked
against a live v2 runtime, none being installed on the development
machine.

Assisted-by: Claude:claude-fable-5-1:Claude Code
ILSpy.Tests.Windows already carries a NetFrameworkProcessesTests fixture
with a Windows PowerShell host and a fuller description check, so the
fixture added to ILSpy.Tests with the lookup duplicated it. The two
lookup cases move next to the tests they belong with and the duplicate
file goes away.

Assisted-by: Claude:claude-fable-5-1:Claude Code
@christophwille
christophwille merged commit fe393d0 into master Sep 21, 2026
15 checks passed
@christophwille
christophwille deleted the fix/process-scan-under-load branch September 21, 2026 06:47
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