Repository navigation
Conversation
Decode mountinfo roots and mount points once in a shared helper, and preserve whitespace in raw cgroup membership paths. Update the consolidated minipal reader and the remaining Mono copy, with portable minipal regression coverage. Co-authored-by: Copilot App <[email protected]>
|
Azure Pipelines: Successfully started running 4 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
jkotas
reviewed
Nov 20, 2026
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Linux CPU-count and automatic GC-budget changes span three runtimes, and incomplete product builds and live resource-limited managed validation leave an integration gap requiring maintainer review.
No open issues 🎉
What changed in this PR
Fixes Linux cgroup path parsing so CPU and memory limit discovery handles whitespace and escaped mount paths correctly. The change covers the shared minipal reader used by CoreCLR and NativeAOT, plus Mono’s separate reader, without changing resource-limit policy or adding public APIs.
Changes:
- Add a shared helper that decodes supported mountinfo escapes exactly once, preserving unknown and truncated sequences.
- Preserve cgroup membership paths through the line ending instead of truncating at whitespace.
- Add six native parsing tests and register them in the native driver and managed launcher.
| File | Description |
|---|---|
src/tests/native/minipal/NativeMinipalTests.cs |
Adds the mountinfo suite to the managed launcher. |
src/tests/native/minipal/native-minipal-tests-driver.c |
Registers the native mountinfo test group. |
src/tests/native/minipal/mountinfo-tests.c |
Tests escapes, decode-once behavior, malformed inputs, capacity limits, and long paths. |
src/tests/native/minipal/CMakeLists.txt |
Includes the new native test source. |
src/native/minipal/mountinfo.h |
Adds shared mountinfo path extraction and decoding. |
src/native/minipal/cgroup.c |
Uses decoded mount paths and preserves membership whitespace. |
src/mono/mono/utils/mono-cgroup.c |
Applies the same parsing fixes to Mono. |
Review effort: Balanced
Keep the parser declaration in the C-compatible header and compile its unchanged implementation once per minipal library. Keep the unescape helper private to mountinfo.c and include the source in regular and AOT minipal builds. Co-authored-by: Copilot App <[email protected]>
jkotas
reviewed
Nov 23, 2026
jkotas
reviewed
Nov 23, 2026
Move the unchanged mountinfo parsing helpers into the shared cgroup reader. Remove the separate helper source/header and the Mono changes. Exercise the existing native cgroup getters with Linux-only procfs fixtures. Co-authored-by: Copilot App <[email protected]>
Compile the real cgroup reader with test-local entrypoints and I/O substitutions instead of GNU linker interposition. Preserve all fixture cases, remove ABI-specific wrappers and the special build definition, and scope includes to the test target. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
krwq
commented
Nov 25, 2026
Use a space-delimited scanset for mountinfo fields and keep decoding private. Focus procfs fixtures on resolved CPU/memory paths, retain decode-once and truncated-escape coverage, and restore the original CMake include setup. Co-authored-by: Copilot App <[email protected]>
This branch has not been deployed
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.
Note
This pull request was generated with GitHub Copilot.
Fixes #137978.
Summary
Fix native Linux cgroup resource-file lookup when membership paths contain literal spaces or tabs, or mountinfo roots/mount points contain escaped path characters. Incorrect lookup can affect
Environment.ProcessorCount, automatic GC memory budgeting, and values exposed byGC.GetGCMemoryInfo().\040,\011,\012and\134, once; preserve unknown and truncated sequences.\x2dpathname text into a hyphen.mountinfosuite in the existing native driver and managed launcher.The change repairs discovery, not CPU/memory policy or kernel enforcement. It does not change
DriveInfoor the already-merged managed mountinfo parser. No public API is added.Validation
Revalidated after porting onto
8867da578c52d4833b09e13b43971badc6614e09, which includes the upstream cgroup consolidation..\build.cmd clr+libs+host.\build.cmd clr.nativesrc\tests\build.cmd -Tree native\minipal x64 Debug /p:LibrariesConfiguration=Debugsrc\tests\build.cmd -GenerateLayoutOnly x64 Debug /p:LibrariesConfiguration=DebugNativeMinipalTestsDriver.execorerun.exe NativeMinipalTests.dllusing that layoutBuilds ran serially through a short worktree path with the installed Visual Studio environment initialized. The portable helper also compiled as C11 and C++17 with
/W4 /WX.On Ubuntu 24.04 x64, rebuilt the actual native
coreclrpal,minipalandaotminipaltargets and ran the expanded minipal driver: all builds passed and the driver passed 32/32.A separate Linux source-fixture matrix compiled the current shared cgroup reader with its real regular-minipal and aotminipal configurations, plus the unchanged Mono reader. It supplies controlled procfs/resource files rather than live cgroup limits:
The shared C reader also passed all 52 cases with GCC ASan+UBSan and leak detection, with no sanitizer diagnostic. Cases cover cgroup v1/v2, raw membership spaces/tabs/trailing spaces, escaped roots/mount points, literal systemd backslashes, decode-once/unknown/truncated sequences, ordinary/private roots, and tighter child versus tighter parent limits. The fixtures require reading the correct child's files so a coincidentally correct ancestor value cannot falsely pass. All seven current source/test file hashes were checked against the local patch.
Remaining integration limit: full Linux CoreCLR/NativeAOT/Mono product builds and a live resource-limited managed application have not been completed. The remote environment had package-restore connectivity, disk-capacity and controller-delegation limits. The issue's numerical managed outputs remain source-derived predictions, not observed application results.
Compatibility and scope
Correct discovery can change processor-count-dependent defaults and automatic GC budgets for the affected path configurations. Explicit processor-count and GC settings retain their existing precedence. Existing cgroup-v2 ancestor-minimum behavior and Mono's existing child-only memory lookup are preserved.
The released-version range and real-world prevalence of the triggering path layouts are not established. This PR targets
main; it does not change the managed mount-path backports.Resolves #137978