Change MolienSeries
to not hang on certain invalid inputs
#5919
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.
When a virtual character that is not an actual character was fed to MolienSeries, that could lead to an infinite loop. The reason in that case was that a quotient of two polynomials was computed that did not produce a polynomial, but rather a rational function. Calling
GcdRepresentation(F, f)
on that as a first step then tried to compute a ring containing both arguments, which ultimately caused the infinite loop.We fix this by passing a parent ring to
GcdRepresentation
which then raises an error in the above situation. The error message of course is not perfect, but note that other invalid inputs already can lead to different errors in other places in the code. Essentially the user is at fault here for passing in garbage. But we make this patch anyway because getting any error is certainly more helpful than an infinite loop.I am not making any claims that this catches all potential hangs, but it certainly resolves #5284 for me.