Skip to content

Fix the crash with -l 1 over the rationals - #419

Open
KainanP wants to merge 1 commit into
algebraic-solving:masterfrom
KainanP:no-tracer-sparse-dense-la
Open

KainanP wants to merge 1 commit into
algebraic-solving:masterfrom
KainanP:no-tracer-sparse-dense-la

Conversation

@KainanP

@KainanP KainanP commented Nov 29, 2026

Copy link
Copy Markdown

Fixes #378.

Over the rationals, initialize_f4 turns on the tracer for every laopt < 40, and that includes -l 1. The exact sparse-dense linear algebra never records a trace, so the learned trace is empty. For the next primes, F4 stops after the input generators, and reduce_final_basis then reads uninitialized basis elements and crashes.

The issue lists several possible fixes. This PR takes the smallest one, which follows an existing precedent: the tracer is not used with -l 1, the same as for the probabilistic linear algebra (-l 42, -l 44). It is a one-line change (laopt > 1 && laopt < 40). -l 1 keeps its own linear algebra, but over the rationals it does not get the speedup from tracing. Recording a trace in the sparse-dense linear algebra (in all three bit widths) would keep that speedup, but it is a much bigger change. I left it out of this PR.

Test

New test/diff/diff_bug-sparse-dense-la-qq.sh runs cyclic5-qq with -l 1, -g 2 and the default parametrization (-P 2 -d 4 -L 0), each with -t 1 and -t 2. It compares the output with the existing output_files/cyclic5-qq.g2.res and cyclic5-qq.P2.d4.res.

  • On master: exits with EXIT: 1, and AddressSanitizer reports a heap-buffer-overflow in reduce_final_basis.
  • With this PR: passes.

Other checks, all on an AddressSanitizer build (-O1 -g -fsanitize=address, FLINT 3.6, Ubuntu 24.04):

  • I ran every input named in the issue (cyclic5-qq, eco6-qq, elim-qq, henrion5-qq, kat7-qq, multy-qq, radical-shape-qq, nonradical-shape-qq, nonradical-radicalshape-qq, nonradical-radicalshape-no-square-qq, choice-linear-form-qq, groebner-g2) with -l 1 and with -l 2, both with -g 2 and with the default output, using -t 1 and a fixed seed. Every run exits 0, and every -l 1 output is byte-identical to the -l 2 output.
  • make check: all 108 existing tests pass. The new test also passes when run through make check after regenerating the Makefile.

AI use: Claude Code (Claude Opus 5.5) wrote the change and the test and ran the checks above. The commit has Claude as co-author.

🤖 Generated with Claude Code

The exact sparse-dense linear algebra (-l 1) does not record a trace,
but F4 learned and applied the tracer with it, as with every option
below 40. The trace stayed empty, so for the next primes F4 stopped
after the input generators and reduce_final_basis read uninitialized
basis elements. Do not use the tracer with -l 1, as is already done for
the probabilistic linear algebra (-l 42, 44).

Fixes algebraic-solving#378

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Segmentation fault with -l 1 over the rationals

1 participant