Repository navigation
builtins(ulimit): normalize Darwin RLIM_INFINITY and print macOS -l/-m/-v rows - #3707
Merged
Merged
Conversation
…s (Refs #3605) run-builtins `ulimit -a` printed `9007199254740991` (unlimited/1024) for the -d/-f/-t rows and `ulimit -f unlimited` failed EPERM for non-root: rubash's internal UNLIMITED sentinel is u64::MAX while Darwin's RLIM_INFINITY is (1<<63)-1, so printone (ulimit.def:754-777 — `curlim == RLIM_INFINITY` prints `unlimited`) never matched and the setrlimit write counted as a hard-limit raise. - rlimit_get normalizes values >= libc::RLIM_INFINITY to UNLIMITED; writes map UNLIMITED back to libc::RLIM_INFINITY (set_limit ulimit.def:578-638 / non-root softening ulimit.def:623-626). - macOS LIMITS table and resource() gain -l/MEMLOCK, -m/RSS and -v/VIRTMEM (Darwin's RLIMIT_AS) so `ulimit -a` prints all eleven rows like print_all_limits over the compiled-in limits[] (ulimit.def:734-749, table ulimit.def:239-298). Byte-verified against GNU Bash 5.3.20 on macOS arm64: `ulimit -a`, `ulimit -Hn/-Sn`, `ulimit -f unlimited`, `ulimit -v/-m/-l`, and the non-root EPERM matrix all match. Known env-bound residual: Darwin rejects lowering RLIMIT_STACK below the already-established stack region for this runtime (issue2636 other-resource cell), GNU's shallower main stack does not trip it. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Member
Author
|
【WIN-AGENT-AUDIT】 机制核查:
腿:
F 点:无 续作记录(本 lane 动过代码):
未跑/VOID 的腿:
|
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.
Summary
ulimit -aon macOS printed9007199254740991for the unlimited rows (andulimit -Hnprinted the raw infinity integer), and non-rootulimit -f unlimitedfailedOperation not permittedwhere GNU returns 0.UNLIMITEDsentinel isu64::MAX, but Darwin'sRLIM_INFINITYis(1<<63)-1— getrlimit values never matched the sentinel, soprintone(third_party/bash/builtins/ulimit.def:754-777,curlim == RLIM_INFINITY→unlimited) divided by the block factor; symmetrically, setrlimit wroteu64::MAX, which the kernel treats as a hard-limit raise above the real maximum → EPERM for theulimit.def:623-626no-op case.rlimit_getnormalizes>= libc::RLIM_INFINITYtoUNLIMITED; all write paths mapUNLIMITEDback tolibc::RLIM_INFINITY. Linux is unaffected (itsRLIM_INFINITYalready equalsu64::MAX).LIMITS/resource()gain-l/MEMLOCK,-m/RSS and-v/VIRTMEM (RLIMIT_AS) undercfg(target_os = "macos"), soulimit -aprints the full eleven rows likeprint_all_limitsover the compiled-inlimits[](ulimit.def:734-749, 239-298). Other non-Linux unix keeps the conservative table.Refs #3605
Verification
ulimit -a,ulimit -Hn/-Sn,ulimit -f unlimited(rc=0, no diagnostic),ulimit -v/-m/-l,ulimit -n unlimitedEPERM edge,-Hsvalue.tests/issue3605_ulimit_infinity_rows.rs: 3 tests green on macOS.run-builtins: ulimit diff eliminated; the remaining diff is the separatehelpbuiltin-table divergence (niu listsenv; GNU has noenvbuiltin) — recorded on macOS: GNU upstream gate 48/86 — catalog of remaining divergences #3605.RLIMIT_STACKbelow the already-established stack region in this runtime →issue2636_subshell_ulimit_isolation::subshell_ulimit_other_resource_does_not_leakfails locally; GNU's shallower main stack does not trip it.