[Scipy-tickets] [SciPy] #1330: special.specfun.jdzo illegally overwrites memory

SciPy Trac scipy-tickets@scipy....
Tue Nov 23 03:06:14 CST 2010


#1330: special.specfun.jdzo illegally overwrites memory
--------------------+-------------------------------------------------------
 Reporter:  dagss   |       Owner:  somebody
     Type:  defect  |      Status:  new     
 Priority:  high    |   Milestone:  0.9.0   
Component:  Other   |     Version:  0.8.0   
 Keywords:          |  
--------------------+-------------------------------------------------------
 If one runs

 {{{
 from scipy.special.specfun import jdzo
 jdzo(1)
 }}}

 *before* any other calls to jdzo, then jdzo will access output arrays out
 of bounds. NOTE that of one first runs, e.g., jdzo(2), then apparently
 memory is initialized so that subsequent calls to jdzo(1) are OK.

 I discovered this by chance when writing a testcase. It is apparent from
 Valgrinding, but more easily reproduced by

 {{{
 diff --git a/scipy/special/specfun/specfun.f
 b/scipy/special/specfun/specfun.f
 index 4b6e890..423781c 100644
 --- a/scipy/special/specfun/specfun.f
 +++ b/scipy/special/specfun/specfun.f
 @@ -429,6 +429,9 @@ C
  40               P(K)=P1(K)
                L1=0
             ELSE IF (L0.NE.0) THEN
 +              IF ((L0+L1).LT.0) THEN
 +                 WRITE (*,*) 'JDZO assumption failed'
 +              ENDIF
                IF (ZO(L0).GE.ZOC(L1)) THEN
                   ZO(L0+L1)=ZO(L0)
                   N(L0+L1)=N(L0)
 }}}

 When this condition fails, the array assignments below obviously write out
 of bounds.

 One simply way to fix it is to initialize all arrays to 0 at the beginning
 of the function. Perhaps a patch will follow, but just filing it for now.

 BTW, what is going on with ZO here, as it starts on 0? Is it simply that
 ZO(0) should always be 0 for all inputs?

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


More information about the Scipy-tickets mailing list