Repository navigation
Closed
Description
Summary
oxiz aborts with a stack overflow (SIGABRT, exit code 134) on a satisfiable QF_UF formula that z3 solves instantly. This is a robustness/crash bug in the EUF handling, surfaced by grammar-driven differential fuzzing against z3.
Reproducer
(set-logic QF_UF)
(declare-sort U 0)
(declare-const c0 U)
(declare-const c1 U)
(declare-const c2 U)
(declare-const c3 U)
(declare-fun f (U) U)
(declare-fun g (U U) U)
(assert (and (and (not (distinct (f (g c0 c3)) (g (f c3) (f c3)))) (distinct (g c3 (f c2)) (g c3 (f c3))) (=> (distinct (g c3 (g c0 c2)) (f c1)) (= c0 (g (f c2) c3)))) (xor (and (distinct (f (f c3)) (f (f c3))) (distinct (g (f c0) (f c2)) (f c0)) (distinct c3 (g c2 (g c3 c1)))) (xor (distinct (g (f c2) (g c3 c2)) (g (f c2) c0)) (distinct (f c0) c2))) (distinct (g (f c1) (f c3)) c2)))
(assert (distinct (g (g c0 c1) (f c2)) (g (g c1 c0) (g c2 c0))))
(assert (= c1 (g (f c0) c2)))
(assert (xor (and (ite (distinct c1 c0) (distinct (f (f c2)) (f (g c3 c2))) (distinct (g (f c2) (f c3)) (f (g c3 c3)))) (not (= (f (f c0)) c3)) (= c1 c0)) (distinct c2 (f (g c0 c1)))))
(assert (not (=> (= c2 (f (f c0))) (=> (= (g (g c3 c2) (g c1 c3)) (f (g c3 c1))) (= c2 c3)))))
(assert (and (xor (or (= c2 (g (g c2 c0) c3)) (= (g (g c2 c1) (f c3)) c1) (distinct c2 (g (f c0) (f c2)))) (not (= (f (f c1)) c1))) (not (distinct (g c2 c0) (g (f c2) c1))) (or (not (distinct (f c2) (g c3 (f c1)))) (and (= (g c1 (f c3)) (g (g c1 c0) c1)) (distinct (g c0 (f c1)) (f (f c2)))) (=> (distinct (f c3) (f (f c2))) (= (f (f c1)) c1)))))
(check-sat)
(exit)Expected
sat
(z3 -in returns sat immediately.)
Actual (oxiz 0.3.0)
The process aborts with a stack overflow:
thread 'main' has overflowed its stack
fatal runtime error: stack overflow, aborting
Aborted (core dumped)
Exit code 134 (SIGABRT). No (error …) is produced and no result is printed — the solver simply crashes.
How found
Grammar-driven differential testing against z3. Of 200 generated QF_UF cases this one caused oxiz to abort while z3 returned sat. The formula is moderately nested (uninterpreted f/g applied to other applications of f/g), which suggests unbounded recursion in term traversal / congruence closure rather than a genuine logic error.
Environment
- oxiz:
0.3.0(built at commitcc28ee2) - z3 (reference):
4.16.0 - reproducer also attached as
cases/uf01_stack_overflow.smt2on branchfeat/grammar-fuzzer
Metadata
Metadata
Assignees
Labels
No labels
Activity
0kenx commentedon Jul 26, 2026
Confirmed fixed. Re-ran the grammar fuzzer over 200 fresh QF_UF cases on the build at
8e930b3: all 200 now agree with z3 (no aborts, no soundness discrepancies). The original reproducer (cases/uf01_stack_overflow.smt2) returnssatas expected instead of aborting. Thanks!cool-japan commentedon Jul 29, 2026
Thanks @0kenx — a real crash, and the case pinned it precisely. Reproduced on
0.3.1: exit 134,fatal runtime error: stack overflow. An lldb backtrace showed the stack filled with one frame,EufSolver::explain_equality, and instrumenting the node pairs it was asked to explain revealed a repeating cycle —(3,0) → (19,2) → (1,0) → (12,6) → (3,0) → …. So this was unbounded recursion, not merely deep recursion. Your read — "unbounded recursion in term traversal / congruence closure rather than a genuine logic error" — was correct on both counts.Root cause: two defects in
oxiz-theories/src/euf/solver.rsthat only bite in combination.propagateappended a congruence proof-forest edge at detection time, during the use-list scan, while the union itself was only queued onpending. If another propagation joined those two classes first, the queued merge was skipped by theroot_a == root_bguard — but the edge stayed. The proof forest must be a spanning forest (one path between any two nodes); a leftover edge gives two, i.e. a cycle.explain_equalitysearched the proof forest for a path fromatoband, for everyCongruenceedge on that path, called itself to explain each argument pair, keeping no record of pairs already being explained. With a cycle present, the path chosen to justify an argument equality could run back through the very congruence edge under explanation, so the self-calls never bottomed out.Fix:
propagate: both assertion and congruence edges are now appended in the main loop after theroot_a == root_bguard, immediately before the union. A merge that turns out to be already satisfied no longer leaves an edge behind, so the proof forest stays a true spanning forest.explain_equality: converted from recursion to an explicit worklist. Congruence argument sub-goals are pushed ontoexplain_todoinstead of being discharged by a self-call, and a companionexplain_enqueuedset expands each node pair at most once, which bounds the loop by the number of distinct pairs. This follows the shape of Z3'seuf_egraph.cppexplain_todoloop.No recursion-depth limit was added: the formula is satisfiable and now answers as such.
Related, found later in the same subsystem and also fixed, since it is the kind of thing your fuzzer would eventually have surfaced:
intern_appimplemented congruence by aliasing — on a signature-table hit it pointed the new term at an older node. That congruence depends on the argument classes holding at that instant, but the dependency was recorded nowhere retractable, andpopdropsterm_to_nodeentries by node index, so an alias to a still-live older node survived the pop that retracted the merge. The result was a term with no node, no use-list entry and no signature of its own, and a second-level congruence that could never be rediscovered — a falsesat. Congruence is now recorded as a retractable merge, matching Z3'segraph::mk. Separately, congruence argument sub-goals were matched positionally while a commutative symbol's canonical signature is sorted, which produced an under-justified (and therefore unsound) conflict core; that is now multiset matching over equivalence classes.Verification: your reproducer now prints
satwith exit code 0, matching z3.test_issue_18_qf_uf_deep_nesting_no_overflowinoxiz-cli/tests/cli_integration.rsruns the exact formula through the realoxizbinary as a subprocess — a genuine 8 MiB main-thread stack — and asserts both a clean exit (not 134) andsat.test_issue_18_deep_congruence_explanation_terminatesexplains a 3000-deep congruence cascade, a depth at which the old recursion overran the stack, and checks the explanation still cites the driving assertion.Will ship with the 0.3.1 release.