Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Python segfaults when printing array in IPython #3962

Closed
beojan opened this Issue · 31 comments

7 participants

@beojan

The code

x = np.linspace(0,10,10000)
x

causes a segfault when run in IPython.

This appears to be caused by numpy/core/src/umath/ufunc_object.c line 272:

if (_extract_pyvals(extobj, ufunc_name,
                        buffersize, errormask, NULL) < 0) 

where _extract_pyvals begins

static int
_extract_pyvals(PyObject *ref, char *name, int *bufsize,
                int *errmask, PyObject **errobj)
{
    PyObject *retval;

    if (ref == NULL) {
        *errmask = UFUNC_ERR_DEFAULT;
        *errobj = Py_BuildValue("NO", PyBytes_FromString(name), Py_None);
        *bufsize = NPY_BUFSIZE;
        return 0;
    }

specifically, the *errobj line causes the segfault

@pv
Owner
pv commented

6d6dc6d ; only in master, not in 1.8.x

@charris
Owner

Works here:

In [1]: x = np.linspace(0,10,10000)

In [2]: x
Out[2]: 
array([  0.00000000e+00,   1.00010001e-03,   2.00020002e-03, ...,
         9.99799980e+00,   9.99899990e+00,   1.00000000e+01])

In [3]: np.__version__
Out[3]: '1.9.0.dev-18acfa4'

Python 2.7, Fedora 19 x86_64.

@seberg
Owner

My guess is that it has something to do with newer Ipython versions (under certain settings) calling some own ufuncs for printing. Maybe @juliantaylor has a quick idea whats going on, I bet it just a missing NULL check.

@juliantaylor

if one disables setting the default errobj (or somehow manages to set it to NULL?) it crashes,
_extract_pyvals function is inconsistent in handling its arguments, I'll fix it.

@beojan

As I said before, it does the same thing with the debian packaged IPython 0.13.2-2

@charris charris closed this issue from a commit
@juliantaylor juliantaylor BUG: fix crash on default errobj
Missing check for optional NULL argument, the case can only happen if
the error mask is 0 (the old default).
closes gh-3962
b52487e
@charris charris closed this in b52487e
@rjurney

I just checked out master and built from source, installed... I get the same segfault in ipython using pandas.

@juliantaylor
Owner

whats the output of:

numpy.__version__
@rjurney

'1.9.0.dev-54d3559'

@juliantaylor
Owner

thats a commit before this issue was fixed, please update to the latest head and try again.

@seberg
Owner

That commit looks like just before the fix was merged.

@rjurney

I have 'git pull origin master' on the master branch from https://github.com/numpy/numpy.git

What other mechanism is there to get to the latest commit?

@charris
Owner

What does .git/config show?

@charris
Owner

That looks good. Hmm... have you reinstalled after the pull?

@rjurney

The pull did nothing, I already had the latest. I'll try reinstalling again... still get version '1.9.0.dev-54d3559'

@charris
Owner

And what is the first commit shown by git log?

@charris
Owner

It is 0ddb6d19cbddee3fae6a0dc8ba5e1151a0d5f553 here.

@charris
Owner

How are you installing?

@rjurney

It is '0ddb6d19cbddee3fae6a0dc8ba5e1151a0d5f553'

python setup.py build
python setup.py install

I don't see the commit looking at the numpy home page. Do you?

@charris
Owner

I think it is this one

commit b52487e026fc25e913b226381b185133ea629fc6
Author: Julian Taylor <jtaylor.debian@googlemail.com>
Date:   Tue Oct 22 20:23:25 2013 +0200

    BUG: fix crash on default errobj

    Missing check for optional NULL argument, the case can only happen if
    the error mask is 0 (the old default).
    closes gh-3962

I wonder if you have done an inplace install at some point? Might try git clean -f.

@charris
Owner

I get

In [1]: np.__version__
Out[1]: '1.9.0.dev-0ddb6d1'

I'm pretty sure you are just loading numpy from the wrong path.

@rjurney

Is there a way for me to figure out whats wrong/where the stale numpy is? Weird that it is a dev version, and I only coulda installed that via the checkout, which is at HEAD?

@juliantaylor
Owner
print numpy
@rjurney

print numpy.version
1.9.0.dev-0ddb6d1

Thanks, I had like 5 numpy's installed. Deleted them all, reinstalled, now I get this :)

And the issue is fixed!

@veronicaoleanderhern

how can i specifically pull the 1.9.0.dev-0ddb6d1 branch?

@charris
Owner

Either git clone https://github.com/numpy/numpy, or browse to that location and fork it, then clone from your version of the repository. Depends on what you want to do after. In any case, the master branch is the development branch.

@rjurney
@charris
Owner

I like to do python setup.py install --user. That version should have priority over other installs and doesn't require permissions.

@veronicaoleanderhern

thanks, solved. it seems like the numpy that's in the scipy superpack is plagued with the error. blowing that copy away and pulling from the numpy repo fixes the pandas.read_csv().

@charris
Owner

Scipy or Numpy superpack? What version and where did you get it?

@rjurney
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.