Skip to content

Fix cgroup v2 memory max extraction#130377

Merged
janvorli merged 3 commits into
dotnet:mainfrom
janvorli:fix-cgroupv2-memory-max-extraction
Jul 9, 2026
Merged

Fix cgroup v2 memory max extraction#130377
janvorli merged 3 commits into
dotnet:mainfrom
janvorli:fix-cgroupv2-memory-max-extraction

Conversation

@janvorli

@janvorli janvorli commented Jul 8, 2026

Copy link
Copy Markdown
Member

In the edge case when the current process is assigned to the root cgroup, the hierarchical memory limit extraction goes past the root cgroup hierarchy mount path and the process ends up crashing.

This was discovered in google colab environment when attempting to run NativeAOT application in a jupyter notebook

Close #130092

In the edge case when the current process is assigned to the root cgroup,
the hierarchical memory limit extraction goes past the root cgroup
hierarchy mount path and the process ends up crashing.

This was discovered in google colab environment when attempting to run
NativeAOT application in a jupyter notebook

Close dotnet#130092
@janvorli janvorli added this to the 11.0.0 milestone Jul 8, 2026
@janvorli janvorli requested a review from jkotas July 8, 2026 21:24
@janvorli janvorli self-assigned this Jul 8, 2026
Copilot AI review requested due to automatic review settings July 8, 2026 21:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a crash in cgroup v2 memory limit discovery by stopping the parent-walk when the current cgroup path reaches the cgroup hierarchy mount (root cgroup case), avoiding attempts to resolve paths above the mount.

Changes:

  • Add an explicit break when cgroupPathLength reaches memory_cgroup_hierarchy_mount_length to prevent walking above the mount path.
  • Change the traversal loop to an unconditional loop (while (true)) relying on the new break condition.

Comment thread src/coreclr/gc/unix/cgroup.cpp
Comment thread src/coreclr/gc/unix/cgroup.cpp
Comment thread src/coreclr/gc/unix/cgroup.cpp Outdated
Copilot AI review requested due to automatic review settings July 8, 2026 23:23
@janvorli

janvorli commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

@mangod9 can you please re-approve? I've modified a comment based on copilot's feedback.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread src/coreclr/gc/unix/cgroup.cpp Outdated
Copilot AI review requested due to automatic review settings July 8, 2026 23:43
@janvorli

janvorli commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

@mangod9 I am sorry, the github UI screwed the multiline comment edit, I had to fix it. Can you please approve it again?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@janvorli janvorli merged commit 0dc2424 into dotnet:main Jul 9, 2026
111 checks passed
@janvorli

janvorli commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

/backport to release/10.0

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Started backporting to release/10.0 (link to workflow run)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NativeAOT executable fails in Google Colab due to inability of finding memory.max

3 participants