Skip to content

Fix a crash when learning the trace with a small initial hash table - #414

Open
jerebertho wants to merge 1 commit into
algebraic-solving:masterfrom
jerebertho:fix-elim-qq-segfault
Open

jerebertho wants to merge 1 commit into
algebraic-solving:masterfrom
jerebertho:fix-elim-qq-segfault

Conversation

@jerebertho

Copy link
Copy Markdown
Contributor

On master, ./msolve -f input_files/elim-qq.ms -g 2 -s 1 crashes while learning the
trace modulo the first prime, with or without -t 1 and -e 1. It works with the
default hash table size.

Some batch insertions in the basis hash table, such as the one of the lcms of the new
pairs in insert_and_update_spairs(), enlarge the table only while it has fewer free
entries than elements to insert (while (esz - eld < n)). They may therefore leave the
table completely full, i.e. eld == esz. Before inserting a single multiplier in
symbol.c, the table was enlarged only when eld == esz - 1, so a full table was not
enlarged and the next insertion wrote past its end. With -s 1 the table has 8 entries
and gets full after the first update.

This PR enlarges the table in these checks as soon as eld >= esz - 1 (4 places in
src/neogb/symbol.c). It also adds -e 1 -g 2 -s 1 with -t 1 and -t 2 to
test/diff/diff_elim-qq.sh; this test fails on master.

Checks:

  • the repro passes under AddressSanitizer for -s from 1 to 20, with and without
    -t 1, and with -e 1; the outputs do not depend on -s;
  • on all input_files, the outputs of -g 2, -g 2 -t 2 and the default call with
    -s 1 are the same as with -s 17, with no AddressSanitizer error;
  • make check passes.

🤖 Generated with Claude Code

Batch insertions such as the one of the pair lcms in
insert_and_update_spairs() only enlarge the hash table while it has
fewer free entries than elements to insert, so they may leave it
completely full (eld == esz). The checks before inserting a single
multiplier in symbol.c only enlarged it when eld == esz-1, so the next
insertion wrote past the end of the table. This made msolve crash while
learning the trace with a small initial hash table, e.g. on elim-qq.ms
with -g 2 -s 1. The checks now also enlarge a full table, and
diff_elim-qq.sh tests -s 1.

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.

2 participants