Conversation
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
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The flake
ProcessExplorerTests.Modules_Of_The_Current_Process_Include_Its_Own_Assembliesfailed in the Windows Release job of #4150 (run 35439301458) withOperationCanceledExceptionafter 1m 00.9s - the test's own 60 sCancellationTokenSource, thrown fromNetFrameworkProcesses.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 failedBuild ILSpyruns 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_ScaninILSpy.Tests.Windows, againOperationCanceledExceptionfromNetFrameworkProcesses.Enumerateat the test's 60 s budget (1m 05s). Different test, same whole-machine scan, so every test that callsGetProcessesAsyncon Windows is exposed.Likely cause
On Windows,
ProcessExplorer.GetProcessesAsyncfinishes with a scan for .NET Framework processes that readProcess.Modulesof every process on the machine to look forclr.dll.Process.Modulesissues 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:StartMenuExperienceHost,LockApp) costing 4 - 11 s eachThe CI job runs
dotnet test --solution ilspy.slnon 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-eraICorPublishused to find managed processes).NetFrameworkProcesses.MayHostDesktopClrdoes that name lookup, and only candidates get the module read, which still supplies the runtime version, the architecture and the confirmation thatclr.dllis loaded.ERROR_FILE_NOT_FOUNDon 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.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
NetFrameworkProcessesTestsfixture inILSpy.Tests.Windows(Windows PowerShell 5.1 as the .NET Framework host):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