Skip to content

CoreCLR: Add missing null guard#126704

Open
trungnt2910 wants to merge 1 commit intodotnet:mainfrom
trungnt2910:patch-1
Open

CoreCLR: Add missing null guard#126704
trungnt2910 wants to merge 1 commit intodotnet:mainfrom
trungnt2910:patch-1

Conversation

@trungnt2910
Copy link
Copy Markdown
Contributor

This fixes Release builds using GCC.

Without this patch, these builds fail with:

  /home/runner/dotnet-runtime/src/coreclr/gc/unix/cgroup.cpp:518:21: error: '%s' directive argument is null [-Werror=format-overflow=]
    518 |         if (asprintf(&mem_usage_filename, "%s%s", s_memory_cgroup_path, filename) < 0)
        |             ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Part of #55803.

Copilot AI review requested due to automatic review settings April 9, 2026 12:36
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Apr 9, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/gc
See info in area-owners.md if you want to be subscribed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a GCC Release build failure in CoreCLR’s Unix cgroup memory usage code by adding a missing null guard before formatting a path string with asprintf, avoiding a -Werror=format-overflow= warning when the cgroup path is null.

Changes:

  • Add an early return in GetCGroupMemoryUsage when s_memory_cgroup_path is null to prevent passing a null %s argument to asprintf.

Copilot AI review requested due to automatic review settings April 9, 2026 12:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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.

Copilot AI review requested due to automatic review settings April 9, 2026 13:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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.

Copy link
Copy Markdown
Member

@janvorli janvorli left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@AustinWise
Copy link
Copy Markdown
Contributor

The equivalent function in Mono ( getCGroupMemoryUsage ) should probably be updated to match.

@trungnt2910
Copy link
Copy Markdown
Contributor Author

Done. I have updated the other file.

It seems like the build configuration for Mono is a bit more lenient towards warnings, so the GCC builds did not report that as an error.

This fixes Release builds using GCC.
Copilot AI review requested due to automatic review settings April 9, 2026 23:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 2 out of 2 changed files in this pull request and generated no new comments.

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

Labels

area-GC-coreclr community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants