Skip to content

feat: stop a runaway solver within seconds on Linux and macOS (stage 11f) - #104

Merged
Sequela02 merged 3 commits into
mainfrom
feat/stage-11-solver-stack-cap
Nov 28, 2026
Merged

Sequela02 merged 3 commits into
mainfrom
feat/stage-11-solver-stack-cap

Conversation

@Sequela02

@Sequela02 Sequela02 commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

cvc5 1.4.2 raises its own stack limit and, on a quantifier over a sequence, recurses without bound (cvc5/cvc5#13161). On Linux it then grows its stack, about 0.7 GB a second, until Accord's time limit kills it. Slice 11f of stage 11 (#83), decision 7 of the 2026-11-13 second set: each solver's stack is capped on Linux and macOS, so that recursion crashes within seconds, which is undecided like any crash.

What it changes

  • On Linux and macOS each solver starts through /bin/sh -c '…' <solver> <args>. The shell lowers the soft and hard stack limit to 256 MiB when the hard limit is above it, then becomes the solver, keeping its process (the time limit still kills it) and its arguments as they are. A hard limit already below the cap stays: macOS's is about 64 MiB, and raising it would fail. The solver starts either way. No dependency and no unsafe. Windows is unchanged.
  • Accord doesn't generate a quantifier over a sequence today (spec functions' axioms are written per term since 11d), so the cap guards against a regression, not a known case.

Measurement

WSL Ubuntu, pinned cvc5 1.4.2 (Linux static build), --mbqi --tlimit-per=10000, memory capped at 4 GB for safety, on the six-line script RUNAWAY in solver.rs:

Stack limit Result
none still running at 20 s, killed by timeout
256 MiB segmentation fault after 5.3 s
64 MiB segmentation fault after 4.3 s
16 MiB segmentation fault after 3.6 s

256 MiB is the largest tried, leaving room for legitimate recursion. On Windows the same script overflows by itself (0xC00000FD) after about 2.4 s.

Verification

  • Tests:
    • a solver that crashes (a stand-in that aborts) gives no answer;
    • a solver that hangs is killed (the existing test);
    • a solver that exhausts its stack (the real cvc5 script) is undecided within half a 30 s limit;
    • Linux and macOS only: ulimit -Hs run through the wrapper reports the cap, or the original limit where it was already lower.
  • On Windows: cargo fmt --all --check passed; cargo clippy --workspace --all-targets --locked -- -D warnings passed, and with --target x86_64-unknown-linux-gnu, which compiles the Unix path; cargo test --workspace --locked: 126 passed, 0 failed, 2 ignored (the crash stand-in and the existing hang stand-in); score.py --self-test and materials.py: passed.
  • By hand in WSL: with an unlimited hard limit the wrapper sets soft and hard to 262144 KiB; under a 65520 KiB hard limit, as on macOS, it leaves 65520; both times the program starts with a b as one argument.
  • CI at 1279a15: linux passed; full-ci passed on Windows and macOS.
  • The first push failed on macOS: the wrapper chained ulimit -s 262144 && exec, and under macOS's lower hard limit ulimit failed, so no solver started. The fix commit lowers the limit only when above the cap and starts the solver either way.

Not established

  • On macOS the cap changes nothing: the system's own limit is lower. cvc5's behavior on the runaway script there wasn't measured by hand; the stack-exhaustion test passes on CI.
  • Whether any legitimate obligation needs more than 256 MiB of solver stack: none in the suite does, if CI passes.

Risk note

Two-way door: one constant and how a solver process starts. Blast radius: every solver run on Linux and macOS; a solver that needed more than 256 MiB of stack would now crash, and its obligation would be undecided, never proved. Evidence: the measurement and checks above, and the full suite on CI.

Refs #83

Atrium: 01a1e493-5da7-7233-b16e-14dba79d4ede

Decision 7 of the 2026-11-13 second set (#83). cvc5 1.4.2 raises its own
stack limit and, on a quantifier over a sequence, recurses without bound
(cvc5/cvc5#13161). On Linux it then grew its stack until the time limit
killed it: on WSL Ubuntu, a six-line script was still running at 20 s,
while capped at 256 MiB it crashed after 5.3 s, and at 16 MiB after 3.6 s.

Each solver now starts through /bin/sh, which caps its soft and hard stack
at 256 MiB and then becomes it, so no dependency or unsafe code is needed.
Tests cover a solver that crashes, one that hangs (already covered), one
that exhausts its stack (the cvc5 script, undecided within half its time
limit) and, on Linux and macOS, that the cap reaches the solver's process.

Refs #83
@Sequela02 Sequela02 added the full-ci Run Windows and macOS CI once before merging label Nov 28, 2026
macOS's hard stack limit is about 64 MiB, below the 256 MiB cap, so
`ulimit -s` failed there and, chained with `&&`, no solver ever ran: the
platforms job on #104 saw every solver give no answer. The wrapper now
lowers the limit only when it is above the cap, and starts the solver
either way. The cap's test ran the stand-in through the test harness,
whose own output came first; it now runs `ulimit -Hs` through the
wrapper directly.

Refs #83
@Sequela02 Sequela02 added full-ci Run Windows and macOS CI once before merging and removed full-ci Run Windows and macOS CI once before merging labels Nov 28, 2026
@Sequela02
Sequela02 merged commit ba4accc into main Nov 28, 2026
5 checks passed
@Sequela02
Sequela02 deleted the feat/stage-11-solver-stack-cap branch November 28, 2026 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Run Windows and macOS CI once before merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant