Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect assert for cgroup file system type #62960

Closed
omajid opened this issue Dec 17, 2021 · 2 comments · Fixed by #72372
Closed

Fix incorrect assert for cgroup file system type #62960

omajid opened this issue Dec 17, 2021 · 2 comments · Fixed by #72372
Assignees
Milestone

Comments

@omajid
Copy link
Member

omajid commented Dec 17, 2021

From mono/mono#21280 (comment):

This is what coreCLR does for the same check:

   struct statfs stats;
   int result = statfs("/sys/fs/cgroup", &stats);
   if (result != 0)
           return 0;

   switch (stats.f_type)
   {
       case TMPFS_MAGIC: return 1;
       case CGROUP2_SUPER_MAGIC: return 2;
       default:
           assert(!"Unexpected file system type for /sys/fs/cgroup");
           return 0;
   }

We both bail if result is not zero from the statfs call. If the f_type not one of the two values I am interested in I just write the message and proceed. It appears coreCLR would abort due to the assert. Should we worry about any message and just proceed with the cgroup checks simply returning false and using the normal system values? It would appear coreCLR is getting a non-zero result as you aren't seeing assertions/aborts when running this with coreCLR. Is something actually mounted at /sys/fs/cgroup when running in your chroot?

We should fix this assert (which just happens to become a no-op at Release builds) to correctly handle environments in which cgroups are not enabled, specially chroots.

cc @akoeplinger @janvorli @tmds

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Dec 17, 2021
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@akoeplinger
Copy link
Member

This isn't mono-specific, moving to area-PAL-coreclr

@janvorli janvorli removed the untriaged New issue has not been triaged by the area owner label Jun 7, 2022
@janvorli janvorli added this to the 7.0.0 milestone Jun 7, 2022
@janvorli janvorli self-assigned this Jun 7, 2022
janvorli added a commit to janvorli/runtime that referenced this issue Jul 18, 2022
When detecting the current cgroup version on Linux, checked and
debug builds assert when the filesystem type of /sys/fs/cgroup is
neither TMPFS_MAGIC nor CGROUP2_SUPER_MAGIC. This change removes
the assert and considers it as "no cgroup support".
Release builds already have this behavior.

Close dotnet#62960
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jul 18, 2022
janvorli added a commit that referenced this issue Jul 22, 2022
* Remove wrong cgroups assert

When detecting the current cgroup version on Linux, checked and
debug builds assert when the filesystem type of /sys/fs/cgroup is
neither TMPFS_MAGIC nor CGROUP2_SUPER_MAGIC. This change removes
the assert and considers it as "no cgroup support".
Release builds already have this behavior.

Close #62960

* Update the nativeaot version too
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jul 22, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Aug 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants