#12217: Finite field polynomials allow division by zero
------------------------------------+------------------------------
       Reporter:  johanbosman       |        Owner:  AlexGhitza
           Type:  defect            |       Status:  needs_review
       Priority:  major             |    Milestone:  sage-5.13
      Component:  basic arithmetic  |   Resolution:
       Keywords:                    |    Merged in:
        Authors:  Peter Bruin       |    Reviewers:  Jeroen Demeyer
Report Upstream:  N/A               |  Work issues:
         Branch:                    |       Commit:
   Dependencies:                    |     Stopgaps:
------------------------------------+------------------------------
Changes (by pbruin):

 * status:  needs_work => needs_review


Old description:

> For prime finite fields, the following causes Sage to crash:
> {{{
> sage: P.<x> = GF(5)[]
> sage: x/0
> ------------------------------------------------------------------------
> Unhandled SIGSEGV: A segmentation fault occurred in Sage.
> This probably occurred because a *compiled* component of Sage has a bug
> in it and is not properly wrapped with sig_on(), sig_off().
> Sage will now terminate.
> ------------------------------------------------------------------------
> }}}
> The cause is a missing check for a zero denominator.  This leads to
> `normalize` in `devel/sage/sage/rings/fraction_field_FpT.pyx` calling
> `nmod_poly_leading(denom)` to get the leading coefficient of the
> denominator. This crashes, since the zero polynomial doesn't have a
> leading coefficient.
>
> And non-prime finite fields don't complain at all:
> {{{
> sage: P.<x> = GF(25,'a')[]
> sage: x/5
> x
> }}}
> This is due to a missing check for division by zero in the `__invert__()`
> method of Givaro finite field elements.  Inserting this check broke
> conversion of the finite field element 0 from Givaro to Gap, so this is
> also fixed.
>
> Apply: [attachment:12217-zero_division.patch]

New description:

 For prime finite fields, the following causes Sage to crash:
 {{{
 sage: P.<x> = GF(5)[]
 sage: x/0
 ------------------------------------------------------------------------
 Unhandled SIGSEGV: A segmentation fault occurred in Sage.
 This probably occurred because a *compiled* component of Sage has a bug
 in it and is not properly wrapped with sig_on(), sig_off().
 Sage will now terminate.
 ------------------------------------------------------------------------
 }}}
 The cause is a missing check for a zero denominator.  This leads to
 `normalize` in `devel/sage/sage/rings/fraction_field_FpT.pyx` calling
 `nmod_poly_leading(denom)` to get the leading coefficient of the
 denominator. This crashes, since the zero polynomial doesn't have a
 leading coefficient.

 And non-prime finite fields don't complain at all:
 {{{
 sage: P.<x> = GF(25,'a')[]
 sage: x/5
 x
 }}}
 This is due to a missing check for division by zero in the `__invert__()`
 method of Givaro finite field elements.  Inserting this check broke
 conversion of the finite field element 0 from Givaro to Gap, so this is
 also fixed.

 Apply: [attachment:12217-zero_division-v2.patch]

--

Comment:

 For division by 0 in the polynomial ring, I decided for 'fraction has
 denominator 0', but because of a different change in
 `polynomial_element.pyx` (see comment:11), you will only see this message
 when trying to construct fraction field elements by coercing a pair of
 elements of the polynomial ring into the fraction field; see the new
 doctest in `fraction_field_FpT.pyx`.

--
Ticket URL: <http://trac.sagemath.org/ticket/12217#comment:12>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to