Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Fix rlimit setting of RLIM_NOFILE on OSX #14054

Merged
merged 1 commit into from
Sep 19, 2017

Conversation

janvorli
Copy link
Member

This change fixes an issue with rlimit setting of RLIM_NOFILE. The problem
is that the rlim_max that we get from getrlimit is too large and so setting
the rlimit_cur to that value fails. The OSX man page for rlimit has a compat
note about it, stating that the rlimit_cur needs to be limited to
min(OPEN_MAX, rlim_max) if one wants to set it to rlim_max.

As an add-on change, I've also adds missing conversion from EMFILE errno
to ERROR_TOO_MANY_OPEN_FILES that has obscured the setrlimit issue since
the failure due to small limit was being reported as ERROR_GEN_FAILURE.

This change fixes an issue with rlimit setting of RLIM_NOFILE. The problem
is that the rlim_max that we get from getrlimit is too large and so setting
the rlimit_cur to that value fails. The OSX man page for rlimit has a compat
note about it, stating that the rlimit_cur needs to be limited to
min(OPEN_MAX, rlim_max) if one wants to set it to rlim_max.
@janvorli janvorli added area-PAL bug Product bug (most likely) labels Sep 19, 2017
@janvorli janvorli self-assigned this Sep 19, 2017
@janvorli
Copy link
Member Author

See https://github.com/dotnet/cli/issues/7247 for details on the issue that lead to discovery of this bug.

@dasMulli
Copy link

dasMulli commented Sep 19, 2017

Does this fix cases where you would need to manually use ulimit to increase the value?
This has been a pain a lot and reported for medium to large NuGet graphs (NuGet/Home#2163, NuGet/Home#2004, https://github.com/dotnet/cli/issues/809) and running tests (microsoft/vstest#578, xunit/xunit#1199).

@janvorli
Copy link
Member Author

@dasMulli this fix ensures that the ulimit is set to the maximum possible value, so yes, it would fix such issues.

@dasMulli
Copy link

Could this possibly be backported to 2.0.x given the number of ppl hitting this (see linked issues and possibly a few more) and it being hard to debug / fix if you don't know what you're looking for?

@janvorli
Copy link
Member Author

@Petermarcu should we still get this to 2.0.2 or would you rather wait for 2.0.3 with this?

Copy link
Member

@adityamandaleeka adityamandaleeka left a comment

Choose a reason for hiding this comment

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

LGTM

@janvorli janvorli merged commit a94de3b into dotnet:master Sep 19, 2017
@janvorli janvorli deleted the fix-osx-rlimit branch September 19, 2017 21:48
@janvorli
Copy link
Member Author

@dasMulli it will be part of the next 2.0 update (2.0.2)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-PAL bug Product bug (most likely)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants