[SciPy-dev] Numeric CVS __array_struct__ interface is broken on 64 bit platforms

Travis Oliphant oliphant at ee.byu.edu
Wed Nov 9 14:16:48 EST 2005


Andrew Straw wrote:

>Hi,
>
>A couple bugs have been reported (including mine last night) which
>indicate a problem with the following bit of code in
>Numerical/Src/arrayobject.c (near line 2200) on 64 bit platforms.  I
>think it'll be a lot faster for someone else to fix it, so I'll leave it
>at this for now.
>
>    if (strcmp(name, "__array_struct__") == 0) {
>        PyArrayInterface *inter;
>        inter = (PyArrayInterface *)malloc(sizeof(PyArrayInterface));
>        inter->version = 2;
>        inter->nd = self->nd;
>        if ((inter->nd == 0) || (sizeof(int) == sizeof(Py_intptr_t))) {
>            inter->shape = (Py_intptr_t *)self->dimensions;
>            inter->strides = (Py_intptr_t *)self->strides;
>        }
>	else {
>	    int i;
>	    for (i=0; i<self->nd; i++) {
>		inter->shape[i] = self->dimensions[i];
>		inter->strides[i] = self->strides[i];
>	    }
>	}
>  
>
Yes, this is a bug,  The else condition is stupid as inter->shape and 
inter->strides don't have any memory allocated.   Only on a 64-bit 
system does the problem show up.

-Travis




More information about the SciPy-Dev mailing list