Repository navigation
Conversation
Confidence Score: 5/5The PR appears safe to merge because no concrete unacknowledged defect remains in the changed behavior. The configured limit is validated before worker startup, propagated through every internal launch path, and exercised by focused regression coverage; the extreme integer-overflow edge case is explicitly acknowledged and deferred. Reviews (1): Last reviewed commit: "no-mistakes(review): validate FM_LINT_SH..." | Re-trigger Greptile |
Run each shard's ShellCheck under a virtual-address-space cap of FM_LINT_SHELLCHECK_MAX_MB (default 4096) so a pathological analysis fails that shard instead of triggering the kernel OOM killer machine-wide. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QF28uDExKvww8KyWtEnP1V
a143e61 to
d87ad36
Compare
|
Rebased onto current main (daaffdb); conflicts resolved in bin/fm-lint.sh and tests/fm-lint.test.sh. Behavior unchanged: main's per-path ShellCheck loop (added by #3778) now runs each invocation under the same FM_LINT_SHELLCHECK_MAX_MB cap as the source-following path. Commit author email rewritten to the GitHub noreply address so the push clears email-privacy checks. |
Intent
The captain reported (2026-09-03): "we just suffered through three OOM crashes due to spellcheck being unbounded. There is a fix that landed locally but you are not tracking that fix yet." The linter bin/fm-lint.sh runs shellcheck per shard with no memory bound; a pathological analysis grew until the kernel OOM killer took down the machine three times. The fix already exists locally as an uncommitted change (bounding each shard's shellcheck with ulimit -v under FM_LINT_SHELLCHECK_MAX_MB, default 4096 MB) and must be shipped so every firstmate home gets it.
What Changed
bin/fm-lint.shnow runs each shard's ShellCheck inside a subshell underulimit -v, capped atFM_LINT_SHELLCHECK_MAX_MB(default 4096 MB) so a pathological analysis fails that shard instead of triggering the kernel OOM killer machine-wide. The cap is best-effort: it is enforced where the platform honors RLIMIT_AS (Linux) and silently ignored elsewhere (macOS).FM_LINT_SHELLCHECK_MAX_MBas a positive integer (exit 2 with a clear message onabc,4G,0,-1), converts it to KiB, and passes it to workers viaFM_LINT_INTERNAL_SHELLCHECK_MAX_KIB, which the--internal-workerentry point now requires.tests/fm-lint.test.shextends the ShellCheck stub to record itsulimit -v, and adds tests asserting the default 4096 MB cap, theFM_LINT_SHELLCHECK_MAX_MB=512override, and rejection of malformed values without running ShellCheck. The cap test self-skips on platforms whereulimit -vis unsupported.Risk Assessment
✅ Low: The change is a contained two-file hotfix: the ulimit wrapper preserves the worker's PID/trap semantics, the parent-side validation rejects every malformed input the prior round identified before any ShellCheck runs, and the new tests assert observable behavior through the real script.
Testing
Completed 1 recorded test check.
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-lint.sh:88- FM_LINT_SHELLCHECK_MAX_MB is fed straight into arithmetic and ulimit with no validation, unlike FM_LINT_JOBS which is validated with a clear message at bin/fm-lint.sh:179-181. Traced concrete inputs: FM_LINT_SHELLCHECK_MAX_MB=abc underset -uaborts the subshell with 'abc: unbound variable' before ShellCheck runs (shard rc=1, message replayed as if it were a lint finding); FM_LINT_SHELLCHECK_MAX_MB=4G fails with 'value too great for base' (rc=1); FM_LINT_SHELLCHECK_MAX_MB=0 setsulimit -v 0so the exec itself dies (observed rc=139 segfault). None of these mention the memory cap, so a user who mistypes the override sees an opaque shard failure and every lint run fails. Fix: validate the value once in the parent alongside JOBS (digits only, greater than zero; reject or treat 0/unlimited explicitly with a clear 'fm-lint.sh: FM_LINT_SHELLCHECK_MAX_MB must be a positive integer' message) and pass the validated KiB value to the worker.bin/fm-lint.sh:34- On platforms where RLIMIT_AS cannot be set (bash on macOS acceptsulimit -vbut the kernel does not enforce it, and some containers pin a lower hard limit), the|| trueand2>/dev/nullmean the cap is silently not applied. That is the right choice for keeping lint runnable, and the test correctly skips there, but the header comment at line 34-36 states the cap unconditionally. Consider wording it as best-effort so an operator on macOS does not assume they are protected. No code change required.🔧 Fix: validate FM_LINT_SHELLCHECK_MAX_MB and document best-effort cap
1 info still open:
bin/fm-lint.sh:196- The validation accepts any digit string, so a value beyond 64-bit range wraps silently in$(( SHELLCHECK_MAX_MB * 1024 )). Traced: FM_LINT_SHELLCHECK_MAX_MB=99999999999999999999 passes the case guard, the arithmetic yields 2123646838278978560 KiB,ulimit -vaccepts it, and ShellCheck runs effectively uncapped with no error. This only affects absurd operator input and the documented cases (abc, 4G, 0, -1) are all rejected correctly, so no change is required for this hotfix; an upper bound on the digit count would close it if desired.bin/fm-test-run.sh --changed --exclude-family real-herdr-gated✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.