"Segmentation fault (core dumped)" as result of matrix multiplication

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

"Segmentation fault (core dumped)" as result of matrix multiplication

Marius Nijhuis
Hello,

I encountered the error "Segmentation fault (core dumped)" during a rather standard multiplication, without excessive memory us.  This looks likes a bug to me?
I am using Python 2.5, Numpy 1.0.4 under Ubuntu 7.10.

Here is what I am doing: i have two arrays, points1 and points2.

points1.shape=(n,k)
points2.shape=(m,k)

The problem only happens if n or m (or both) are 1. The arrays are then still 2-dimensional. k is usually in the order of 60.

The code:

        p1Mat=asmatrix(points1)
        p2Mat=asmatrix(points2).T
        ab=p1Mat*p2Mat

At the third line, python crashes back to terminal with the text  "Segmentation fault (core dumped)"
Tracing further the error happens at line 106 of numpy/core/defmatrix.py
If I understand correctly, the   __mul__   method of p1Mat calls    N.dot(self, asmatrix(other))
and the problem occurs in    asmatrix(other)  , i.e. before actual multiplication is done.

To be more precise, at some point the code calls __array_finalize__ twice, nested, and the error happens on the second return from it.  I am not 100% sure what is done here, but it looks as if the  asmatrix command I gave myself is somehow conflicting with the asmatrix command given by __mul__

I have replaced my code with:

        p1Mat=sp.matrix(points1)
        p2Mat=sp.matrix(points2).T
        ab=p1Mat*p2Mat

and this works fine.

I hope this information is useful to someone?

Marius





_______________________________________________
Numpy-discussion mailing list
[hidden email]
http://projects.scipy.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|

Re: "Segmentation fault (core dumped)" as result of matrix multiplication

Pauli Virtanen-3
ti, 2008-05-06 kello 14:15 +0200, Marius Nijhuis kirjoitti:

> Hello,
>
> I encountered the error "Segmentation fault (core dumped)" during a
> rather standard multiplication, without excessive memory us.  This
> looks likes a bug to me?
> I am using Python 2.5, Numpy 1.0.4 under Ubuntu 7.10.
>
> Here is what I am doing: i have two arrays, points1 and points2.
>
> points1.shape=(n,k)
> points2.shape=(m,k)
>
> The problem only happens if n or m (or both) are 1. The arrays are
> then still 2-dimensional. k is usually in the order of 60.

If you got the arrays by unpickling them and you are using a SSE2
enabled Atlas, this sounds like bug #551
(http://scipy.org/scipy/numpy/ticket/551#comment:22) to me. Is this the
case? Can you reproduce a segmentation fault with the simple C-only test
case?

--
Pauli Virtanen


_______________________________________________
Numpy-discussion mailing list
[hidden email]
http://projects.scipy.org/mailman/listinfo/numpy-discussion