[Scipy-tickets] [SciPy] #1564: Integer overflows cause segfault in linkage function with large input

SciPy Trac scipy-tickets@scipy....
Sat Nov 19 21:15:58 CST 2011


#1564: Integer overflows cause segfault in linkage function with large input
---------------------------+------------------------------------------------
 Reporter:  laserson       |       Owner:  somebody
     Type:  defect         |      Status:  new     
 Priority:  high           |   Milestone:  0.11.0  
Component:  scipy.cluster  |     Version:  devel   
 Keywords:  linkage        |  
---------------------------+------------------------------------------------
 Hi all,

 I have been looking for the source of some segfaults I have been getting
 when trying to use the linkage function in scipy.cluster.hierarchy, and I
 finally found the reason (with the help of our cluster's IT person, Chris
 Walker).

 In the 'linkage' function in hierarchy.c, the three variables `n`, `np`,
 and `npc2`, are declared as int types.  However, if `n=50000`, which is
 the case with my input files, then the value of NCHOOSE2(n) overflows,
 leading `malloc` to return a null pointer because the requested number of
 bytes is negative.

 If you uncomment the debug message at l. 461, you will find this to be
 true.

 These three variables should be changed to be long ints, or something
 similar, to accomodate larger input matrices.

 Thanks!
 Uri

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/1564>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list