Python segfaults when printing array in IPython #3962

Closed
beojan opened this Issue Oct 22, 2013 · 31 comments

Projects

None yet

7 participants

@beojan
beojan commented Oct 22, 2013

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

Owner
pv commented Oct 22, 2013

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

Owner
charris commented Oct 22, 2013

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.

Member
seberg commented Oct 22, 2013

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.

Contributor

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 commented Oct 22, 2013

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

@charris charris pushed a commit that closed this issue Oct 23, 2013
@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 Oct 23, 2013
rjurney commented Nov 1, 2013

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

Contributor

whats the output of:

numpy.__version__
rjurney commented Nov 1, 2013

'1.9.0.dev-54d3559'

Contributor

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

Member
seberg commented Nov 1, 2013

That commit looks like just before the fix was merged.

rjurney commented Nov 1, 2013

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?

Owner
charris commented Nov 1, 2013

What does .git/config show?

Owner
charris commented Nov 1, 2013

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

rjurney commented Nov 1, 2013

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

Owner
charris commented Nov 1, 2013

And what is the first commit shown by git log?

Owner
charris commented Nov 1, 2013

It is 0ddb6d19cbddee3fae6a0dc8ba5e1151a0d5f553 here.

Owner
charris commented Nov 1, 2013

How are you installing?

rjurney commented Nov 1, 2013

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?

Owner
charris commented Nov 1, 2013

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.

Owner
charris commented Nov 1, 2013

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 commented Nov 1, 2013

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?

Contributor
print numpy
rjurney commented Nov 1, 2013

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!

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

Owner
charris commented Nov 4, 2013

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 commented Nov 4, 2013

Then you'll need to uninstall numpy (do this first, and make sure import
numpy fails, I had multiple versions lying around), and python setup.py
build/install

On Mon, Nov 4, 2013 at 3:43 PM, Charles Harris notifications@github.comwrote:

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.


Reply to this email directly or view it on GitHubhttps://github.com/numpy/numpy/issues/3962#issuecomment-27734713
.

Russell Jurney twitter.com/rjurney russell.jurney@gmail.com datasyndrome.com

Owner
charris commented Nov 5, 2013

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

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().

Owner
charris commented Nov 5, 2013

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

rjurney commented Nov 5, 2013

Believe he means this thing http://fonnesbeck.github.io/ScipySuperpack/

On Mon, Nov 4, 2013 at 8:29 PM, Charles Harris notifications@github.comwrote:

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


Reply to this email directly or view it on GitHubhttps://github.com/numpy/numpy/issues/3962#issuecomment-27747021
.

Russell Jurney twitter.com/rjurney russell.jurney@gmail.com datasyndrome.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment