Skip to content

Conversation

grhkm21
Copy link
Contributor

@grhkm21 grhkm21 commented Jan 26, 2024

Fix #37169.
Fix #37317.

Changes: adding sig_on() and sig_off() where appropriate.

yyyyx4 and others added 4 commits January 22, 2024 15:32
...because attempting to run this with unhashable elements throws the
same exception, which can cause confusion in higher-level algorithms.
…exist"

This reverts commit 8b38164, which is
from another PR.
Copy link
Contributor

@GiacomoPope GiacomoPope left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small comments, but otherwise this looks good. Happy to remove after changes / discussion.

@grhkm21 grhkm21 requested a review from GiacomoPope February 10, 2024 15:38
@grhkm21
Copy link
Contributor Author

grhkm21 commented Feb 10, 2024

Sorry for the delay :)

@grhkm21 grhkm21 changed the title Fix two polynomial SIGABRT bugs #37169 Fix three polynomial SIGABRT bugs #37169 Feb 13, 2024
@grhkm21
Copy link
Contributor Author

grhkm21 commented Feb 13, 2024

Also fixed the following bug reported by @hellman #37317

sage: x = Zmod(10)['x'].gen()
sage: f = 2*x + 3
sage: gcd(f, f)

In the future all nmod_poly_* or even nmod_* functions should be carefully reviewed to look at its assumptions.

ye

Co-authored-by: Giacomo Pope <44242839+GiacomoPope@users.noreply.github.com>
@GiacomoPope
Copy link
Contributor

Worth directly linking this to: #37317

@grhkm21
Copy link
Contributor Author

grhkm21 commented Feb 13, 2024

Ahh I didn't see it, thanks!

@grhkm21 grhkm21 changed the title Fix three polynomial SIGABRT bugs #37169 Fix three polynomial SIGABRT bugs #37169 and #37317 Feb 13, 2024
@GiacomoPope
Copy link
Contributor

Waiting for CI to do it's thing before approving, but this all seems good to me now i think

@grhkm21
Copy link
Contributor Author

grhkm21 commented Feb 14, 2024

It seems the CI fail is unrelated to this PR.

@vbraun
Copy link
Member

vbraun commented Feb 17, 2024

Failure is from this PR. Please do test it yourself before coming to the conclusion that "the CI is not working".

@GiacomoPope
Copy link
Contributor

GiacomoPope commented Feb 21, 2024

Your change to the gcd to return a monic polynomial now leads to a value error for:

sage: R.<x> = Zmod(4)[]
sage: f = R(2 * x)
sage: f.gcd(f)
ValueError: leading coefficient must be invertible

So the doctest is failing.

@grhkm21
Copy link
Contributor Author

grhkm21 commented Feb 21, 2024

Will fix when back, sorry for that :(

Copy link
Contributor

@GiacomoPope GiacomoPope left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a few questions, but nothing holding back merging IMO

sage: c * Zmod(2).zero()
Traceback (most recent call last):
...
RuntimeError: Aborted
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the best error we can give the user?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how to properly catch/handle all erroring cases in Python. I don't even understand why this is erroring right now, so it is probably best to leave this for now. Maybe a better way is for sig_on() sig_off() to return the runtime exception message or something

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiplication by zero should just be fine though... right? So my guess is there's some case where the flint code ensures the parents are the same and when they're not the code crashes?

@grhkm21
Copy link
Contributor Author

grhkm21 commented Feb 27, 2024 via email

@GiacomoPope
Copy link
Contributor

Ahh ok, well it would be nice to try and print this a little nicer, but if we can't then that's OK

@grhkm21
Copy link
Contributor Author

grhkm21 commented Mar 26, 2024

@GiacomoPope When you are free, feel free to go through it again and approve if it's good :D Thanks

Copy link
Contributor

@GiacomoPope GiacomoPope left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one comment about potentially unused variables

@@ -578,15 +578,18 @@ cdef inline int celement_gcd(nmod_poly_t res, nmod_poly_t a, nmod_poly_t b, unsi
sage: (G//d)*d == G
True
"""
cdef unsigned long leadcoeff, modulus, leadcoeff_res
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these variables used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, thanks for spotting

@GiacomoPope
Copy link
Contributor

LGTM -- might be worth ensuring the branch is up to date with the master

Copy link

Documentation preview for this PR (built with commit 4d7c349; changes) is ready! 🎉

@vbraun vbraun merged commit 2217e9e into sagemath:develop Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash on gcd of polynomials over rings SIGABRT Two polynomial SIGABRT bugs
5 participants