#14254: OverflowErrors in TripleDictEraser
----------------------------+-----------------------------------------------
       Reporter:  jdemeyer  |         Owner:  robertwb
           Type:  defect    |        Status:  new     
       Priority:  blocker   |     Milestone:  sage-5.8
      Component:  coercion  |    Resolution:          
       Keywords:            |   Work issues:          
Report Upstream:  N/A       |     Reviewers:          
        Authors:            |     Merged in:          
   Dependencies:            |      Stopgaps:          
----------------------------+-----------------------------------------------

Comment (by SimonKing):

 How many bytes is Py_ssize_t using? On 32-bit machines, is Py_ssize_t
 perhaps using more bytes than size_t? Then, the problem could be here:
 {{{
         cdef Py_ssize_t h1 = <Py_ssize_t><void *>k1
         cdef Py_ssize_t h2 = <Py_ssize_t><void *>k2
         cdef Py_ssize_t h3 = <Py_ssize_t><void *>k3
         cdef Py_ssize_t h = (h1 + 13*h2 ^ 503*h3)
 }}}
 While h1, h2, and h3 should be fine (they are obtained from a pointer and
 are thus using 32 bit), I could imagine that Python tries to be clever and
 uses more byte (long versus int) for h, if 13*h2 or 503*h3 happen to be
 larger than the greatest number representable by 32 bit.

 If this is the case, then the line
 {{{
 cdef list bucket = <object>PyList_GET_ITEM(all_buckets, (<size_t>h) %
 PyList_GET_SIZE(all_buckets))
 }}}
 (when the "long" Py_ssize_t h is converted down to 32 bit of size_t) could
 overflow, isn't it?

 Caveat: I am not an expert for the subtleties of Py_ssize_t on 32 versus
 64 bit...

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14254#comment:10>
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to