3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-06-19 23:26:30 +00:00
z3/src/math
Copilot b74e35f4fb
Fix mpz_manager leak in algebraic root comparison (#9654)
A `root-obj`-driven unsat case was exiting with a leaked `mpz_manager`
allocation even though solver output was correct. The leak came from
temporary rational bounds created during algebraic-number comparison and
not released before shutdown.

- **Root cause**
- `algebraic_numbers::compare_core()` materialized interval bounds as
raw `mpq` temporaries.
- Those temporaries could allocate backing `mpz` storage, but their
lifetime was not tied to the manager, so the allocator retained leaked
cells at process exit.

- **Change**
- Replace the raw `mpq` temporaries with `scoped_mpq` in
`/src/math/polynomial/algebraic_numbers.cpp`.
- This keeps the comparison logic unchanged while making temporary bound
conversion use RAII-managed cleanup.

- **Effect**
- `root-obj` comparisons no longer leave `mpz_manager` allocations
behind.
- Solver behavior is unchanged; the fix is limited to temporary numeral
lifetime management.

```c++
- mpq l_a, u_a, l_b, u_b;
+ scoped_mpq l_a(qm()), u_a(qm()), l_b(qm()), u_b(qm());
```

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-05-28 09:06:05 -07:00
..
dd Remove unused swap() methods (#8538) 2026-02-08 18:53:43 +00:00
grobner Standardize for-loop increments to prefix form (++i) (#8199) 2026-01-14 19:55:31 -08:00
hilbert Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
interval Fix 13 compiler warnings: sign-comparison and unused parameters (#8215) 2026-01-16 16:00:42 -08:00
lp nla_grobner: add mod_residue pattern to propagate_quotients (#9597) 2026-05-26 18:12:38 -07:00
polynomial Fix mpz_manager leak in algebraic root comparison (#9654) 2026-05-28 09:06:05 -07:00
realclosure Code simplifications in sls_euf_plugin.cpp and realclosure.cpp 2026-03-10 16:17:24 +00:00
simplex Fix static analysis findings: uninitialized vars, bitwise shift UB, garbage values 2026-03-02 00:13:55 +00:00
subpaving Standardize for-loop increments to prefix form (++i) (#8199) 2026-01-14 19:55:31 -08:00