proof-solvers: a time limit on every z3 goal, and a deadline on its I/O #239
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/z3-goal-deadline"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What was wrong
The resident
z3session had no time limit. If z3 could not decide a goal, that one goal held the session for as long as z3 kept working on it. Every goal queued behind it waited too. The one-shot z3 had the same problem.The fix
Every goal now has two limits, on both the resident session and the one-shot rung.
-t:(GOAL_TIMEOUT, 60 s by default, set withZ3Server::with_goal_timeout). At the limit,(check-sat)answersunknown. The goal counts as undecided, never proved, and the session goes on to the next goal.(set-option :timeout …). So the write and the read both give upGOAL_DEADLINE_GRACE(5 s) past the soft limit. At that point:z3 reads its input only as it reaches each command. A goal can contain its own
(check-sat)followed by more than a pipe buffer of text. Such a goal blocked the write on the calling thread for as long as that check ran, where no read deadline could stop it. So both ends of the pipe are now on threads of their own:output_within.Checked
z3 behaviour. Checked on Homebrew z3 5.1.0 (build host) and on Ubuntu's 4.8.12, the version the CI image installs:
unknowncomes at the soft limit;:timeoutlifts that limit, even after(reset);unknown;(check-sat).Tests. Five new tests, on a goal z3 cannot decide in seconds (32-bit factors of a 64-bit semiprime):
a_goal_past_its_limit_is_unknown_and_the_session_decides_ona_goal_that_lifts_its_limit_is_cut_off_at_the_deadline: the session's z3 is gone after the dropa_goal_too_long_to_write_is_cut_off_at_the_deadlinea_one_shot_z3_is_killed_at_the_deadline: both ends, and the pid is checkedthe_server_keeps_its_goal_limit_across_sessions: the builder, and the replacement session keeps the limitMutation checks. Each mutation fails at least one of the new tests:
-t:;Build host.
cargo test --workspace(proof-rs) passes.clippy -p proof-solvers --all-targets -D warningsis clean.proof-conformancepasses all checks.gen-vectorsoutput is byte-identical toproof/conformance/v1; the conformance ladder holds no z3.🤖 Generated with Claude Code