#11771: sage crashes on some degenerate flint xgcd's
--------------------------------+-------------------------------------------
   Reporter:  lftabera          |          Owner:  AlexGhitza                   
                    
       Type:  defect            |         Status:  needs_review                 
                    
   Priority:  critical          |      Milestone:  sage-4.7.2                   
                    
  Component:  basic arithmetic  |       Keywords:  flint, crash, xgcd fmpq_poly 
rational polynomials
Work_issues:                    |       Upstream:  N/A                          
                    
   Reviewer:                    |         Author:  Leif Leonhardy               
                    
     Merged:                    |   Dependencies:                               
                    
--------------------------------+-------------------------------------------

Comment(by spancratz):

 I can confirm that the patch suggested by leif does the right thing.  It
 does have one extra re-allocation, though, which isn't necessary.  I
 suggest the following,

 {{{
     limbs = FLINT_MAX(fmpz_size(s->den), fmpz_size(t->den)) +
 fmpz_size(rop->den);
     temp  = fmpz_init(limbs);
 }}}

 which might perhaps also be easier to read as it's two lines shorter?

 Also, the two subsequent calls to fmpq_poly_canonicalize() should be
 replaced by

 {{{
     fmpq_poly_canonicalize(s, NULL);
     fmpq_poly_canonicalize(t, NULL);
 }}}

 If you look at the code for fmpq_poly_canonicalize() you'll see that this
 is in fact not necessary at all since the function doesn't ever actually
 use the temporary space passed in anyway.  ---  I realise this looks
 rather bad.  If you think this should be cleaned up on the occasion of
 this ticket, let me know.  ---

 In any case, the above bit of code fixes this issue.

 By the way, the tight re-use of fmpz variables in flint1 together with the
 manual memory management is one of the biggest pains when working with
 flint1.  This is all much, much easier in flint2.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11771#comment:20>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to