Skip to content

Conversation

@kylehofmann
Copy link
Contributor

Sometimes FLINT fails to calculate GCDs in polynomial rings over Z/nZ. Since FLINT has no interface to report the failure, the GCD calculation needs to be wrapped and an error thrown. The present method of wrapping does not properly reactivate signals if an error happens, because the exception causes sig_off() to never be reached. This patch rectifies that. It also adds a doctest which triggers this code path; the example is designed so that the GCD exists but FLINT fails.

The error message is also adjusted, since the failure condition is more complicated than just encountering non-invertible elements (e.g., in Z/6, gcd(2*x, x) will work).

@github-actions
Copy link

github-actions bot commented Sep 27, 2024

Documentation preview for this PR (built with commit b7ae8b0; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@kylehofmann kylehofmann force-pushed the crash-in-flint-z-nz-polynomial-gcd branch from a67bebe to 24fc9a2 Compare September 28, 2024 22:05
Copy link
Collaborator

@tscrim tscrim left a comment

Choose a reason for hiding this comment

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

Two very minor things. Otherwise LGTM.

@kylehofmann kylehofmann requested a review from tscrim October 5, 2024 15:41
Copy link
Collaborator

@tscrim tscrim left a comment

Choose a reason for hiding this comment

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

Thank you. Positive review.

vbraun pushed a commit to vbraun/sage that referenced this pull request Oct 9, 2024
sagemathgh-38719: Change wrapping of FLINT Z/nZ polynomial gcd failure
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Sometimes FLINT fails to calculate GCDs in polynomial rings over Z/nZ.
Since FLINT has no interface to report the failure, the GCD calculation
needs to be wrapped and an error thrown. The present method of wrapping
does not properly reactivate signals if an error happens, because the
exception causes `sig_off()` to never be reached. This patch rectifies
that. It also adds a doctest which triggers this code path; the example
is designed so that the GCD exists but FLINT fails.

The error message is also adjusted, since the failure condition is more
complicated than just encountering non-invertible elements (e.g., in
Z/6, `gcd(2*x, x)` will work).
    
URL: sagemath#38719
Reported by: Kyle Hofmann
Reviewer(s): Kyle Hofmann, Travis Scrimshaw
@vbraun vbraun merged commit c8ac1dc into sagemath:develop Oct 12, 2024
@kylehofmann kylehofmann deleted the crash-in-flint-z-nz-polynomial-gcd branch October 12, 2024 21:22
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.

4 participants