Skip to content

fix(bin): retry ShellCheck roots that hit the memory ceiling without --external-sources - #14

Merged
sctru merged 1 commit into
mainfrom
fm/fm-lint-shellcheck-oom
Oct 4, 2026
Merged

sctru merged 1 commit into
mainfrom
fm/fm-lint-shellcheck-oom

Conversation

@sctru

@sctru sctru commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Problem

CI "Lint 1" fails with shellcheck: out of memory (exit 251) on bin/fm-teardown.sh, on main (runs 37162304110, 37165495594) and on PR #13 (run 37166350107).
The root peaks at about 8.39 GB resident in CI with --external-sources (8.38 GB reproduced locally, 61 s), right at the runner's memory limit, which is why one PR #12 rerun passed.

Cause

This fork's main predates upstream's memory fallback (kunchenguid/firstmate kunchenguid#6443, d719ef3).
Without it, a root that hits the memory ceiling fails lint outright.

Fix

Cherry-pick d719ef3 unchanged (bin/fm-lint.sh, tests/fm-lint.test.sh, docs/fm-test-portable-shards.md).
A root that exhausts memory with --external-sources is retried once without it under the same deadline, excluding only the cross-file codes (SC1091, SC2034, SC2153, SC2329).
fm-teardown.sh stays linted, and other findings still fail.

Measurements for bin/fm-teardown.sh

  • Before: --external-sources, rc 251 in CI at 8,391,476 KiB peak RSS; main without the fallback.
  • After, forcing the memory ceiling locally (FM_LINT_REQUIRE_BOUNDS=1 FM_LINT_ROOT_MEMORY_KIB=8388608): reason memory-fallback, rc 0, final no-sources attempt about 0.79 GB RSS in 3.7 s.
  • At the default 12 GiB cap the source-following pass still fits locally (8.38 GB); the fallback now covers runners where it does not.

Note: the source-following analysis of fm-teardown.sh is itself near the limit and growing, so a later reduction of its sourced graph may still be worthwhile; that is out of scope here.

…--external-sources (kunchenguid#6443)

* fix(lint): retry memory-bound roots without external sources

* no-mistakes(review): Make fallback tests portable and correct source-following telemetry

* no-mistakes(review): Remove committed parity fixtures and use disposable test roots

* no-mistakes(document): Document ShellCheck memory fallback and telemetry

* no-mistakes(review): Cover bounded and unbounded fallback RSS behavior

* no-mistakes(document): Correct stale lint fallback documentation

* no-mistakes(document): Correct stale lint test documentation

* no-mistakes(ci): The memory fallback (the retry without --external-sources) now gets only the time left in its root's original deadline, so it can no longer outlast the CI job. Invariant: one root's first attempt plus its fallback must fit inside a single FM_LINT_ROOT_SECONDS deadline, plus the cleanup grace. Only one site started a new deadline: the fallback call in fm_lint_run_root. The deadline is the only budget involved, because the memory limit already applies to each process separately. Changes in bin/fm-lint.sh: - fm_lint_exec_root now takes a <seconds> argument instead of always reading FM_LINT_INTERNAL_ROOT_SECS. - The first attempt passes the full deadline. - The fallback passes floor((start + deadline - now) / 1000) seconds. - When bounds are enforced and less than 1 second is left, no retry starts. fm_exec_timed rejects 0 seconds, so the retry cannot run with no time. The root keeps reason=memory, and the shard output says "no time left in its Ns deadline to retry without it". - Unbounded local runs have no deadline and behave as before. - The header comment now describes the shared deadline. Changes in tests/fm-lint.test.sh: a new test, test_memory_fallback_spends_only_the_remaining_root_deadline, runs only on hosts that can enforce bounds. It uses a 6 s deadline and 1 s grace. - Case 1: the first attempt runs 3 s and then fails with memory status 251. The test asserts one fallback ran, reported reason=timeout, and the root's recorded duration is under 7000 ms. - Case 2: the first attempt runs 5.2 s. The test asserts no fallback starts, the skip is explained, and the sidecar records memory with source-following 1. Verification: - Full `nice -n 10 bash tests/fm-lint.test.sh` passed, including the new test, in about 5 minutes. - Case 1 run against the HEAD script: the root took 9168 ms, so the under-7000 ms check fails before the fix. - `bin/fm-lint.sh bin/fm-lint.sh tests/fm-lint.test.sh` reported no findings. - The CI workflow is unchanged, so the Test step still runs only tests/fm-lint.test.sh with nice -n 10 and the 12 GiB ShellCheck limit
@sctru
sctru force-pushed the fm/fm-lint-shellcheck-oom branch from 2ca0f57 to 56f1df6 Compare October 4, 2026 06:21
@sctru
sctru merged commit ac762f0 into main Oct 4, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants