#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:
Report Upstream:  N/A               |  Work issues:
         Branch:                    |       Commit:
   Dependencies:                    |     Stopgaps:
------------------------------------+----------------------------
Changes (by {'newvalue': u'Peter Bruin', 'oldvalue': ''}):

 * status:  new => needs_review
 * author:   => Peter Bruin


Old description:

> For prime finite fields, Sage (and the attached `gdb`!) 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 reason is that `normalize` in
> `devel/sage/sage/rings/fraction_field_FpT.pyx` calls `
> 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
> }}}

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.patch]

--

--
Ticket URL: <http://trac.sagemath.org/ticket/12217#comment:8>
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