Fix 32-bit overflow in exponent-vector indexing - #355
Open
dcposch wants to merge 1 commit into
Open
Conversation
Co-Authored-By: Grok via the JC2 campaign
Author
|
Minimized reproduction example, Python generator: nvars, nterms = 10000, 214750 # last index × nvars just exceeds INT32_MAX
open("repro.ms","w").write(
",".join(f"x{i}" for i in range(nvars)) + "\n105337\n"
+ "+".join(["x0"] * nterms) + "\n") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On inputs whose total number of terms times the number of variables exceeds
INT32_MAX, msolve segfaults while parsing:(pos+j)*nvarsis evaluated in 32-bit signed arithmetic, sostore_exponent()is called with a negative offset (gdb:pos=-2147477296atiofiles.c:58, called fromget_coefficient_ff_and_term_from_line).This patch uses 64-bit indexing for exponent-vector offsets and allocations (parser, F4 import, and the variable-order swap).
Minimized reproducer (10000 variables, 214750 terms of
x0over a prime field, ~700KB): unpatched 0.10.1 dies with the backtrace above; patched computes a Groebner basis.make check: 64/64 pass.