#11551: Pari segfault on Sage startup in Cygwin
------------------------+---------------------------------------------------
   Reporter:  kcrisman  |          Owner:  tbd       
       Type:  defect    |         Status:  new       
   Priority:  major     |      Milestone:  sage-4.7.2
  Component:  cygwin    |       Keywords:  pari      
Work_issues:            |       Upstream:  N/A       
   Reviewer:            |         Author:            
     Merged:            |   Dependencies:            
------------------------+---------------------------------------------------

Comment(by kcrisman):

 I put in print statements at every conceivable place.  Here is as far as
 it gets:
 {{{
     def _pari_(self):
 <snip comments/docs>
         sig_on()
         if mpfr_nan_p(self.value) or mpfr_inf_p(self.value):
             raise ValueError, 'Cannot convert NaN or infinity to Pari
 float'

         # wordsize for PARI
         cdef unsigned long wordsize = sizeof(long)*8

         cdef int prec
         prec = (<RealField_class>self._parent).__prec

         # We round up the precision to the nearest multiple of wordsize.
         cdef int rounded_prec
         rounded_prec = (self.prec() + wordsize - 1) & ~(wordsize - 1)

         # Yes, assigning to self works fine, even in Pyrex.
         if rounded_prec > prec:
             self = RealField(rounded_prec)(self)

         cdef mpz_t mantissa
         cdef mp_exp_t exponent
         cdef GEN pari_float

         if mpfr_zero_p(self.value):
             pari_float = real_0_bit(-rounded_prec)
         else:
             # Now we can extract the mantissa, and it will be normalized
             # (the most significant bit of the most significant word will
 be 1).
             mpz_init(mantissa)
             exponent = mpfr_get_z_exp(mantissa, self.value)

 WE GET HERE AND NO FURTHER

             # Create a PARI REAL
             pari_float = cgetr(2 + rounded_prec / wordsize)
             mpz_export(&pari_float[2], NULL, 1, wordsize/8, 0, 0,
 mantissa)
             mpz_clear(mantissa)
             setexpo(pari_float, exponent + rounded_prec - 1)
             setsigne(pari_float, mpfr_sgn(self.value))

         cdef PariInstance P
         P = sage.libs.pari.all.pari
         return P.new_gen(pari_float)
 }}}
 Since
 {{{

     # level1.h (incomplete!)

     GEN     cgetg_copy(long lx, GEN x)
     GEN     cgetg(long x, long y)
     GEN     cgeti(long x)
     GEN     cgetr(long x)
     long    itos(GEN x)
     GEN     real_0_bit(long bitprec)
     GEN     stoi(long s)
 }}}
 so `cgetr` is indeed from level1.h, which is where the `sage -gdb`
 backtrace ends up before raising the interrupt.   What would get that to
 have problems?

 Also attaching screenshot of the traceback.

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