Skip to content

Python segfaults when printing array in IPython #3962

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Python segfaults when printing array in IPython #3962

beojan opened this issue Oct 22, 2013 · 31 comments

Comments

@beojan
Copy link

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

@pv
Copy link
Member

pv commented Oct 22, 2013

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

@charris
Copy link
Member

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.

@seberg
Copy link
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.

@juliantaylor
Copy link
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
Copy link
Author

beojan commented Oct 22, 2013

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

@rjurney
Copy link

rjurney commented Nov 1, 2013

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

@juliantaylor
Copy link
Contributor

whats the output of:

numpy.__version__

@rjurney
Copy link

rjurney commented Nov 1, 2013

'1.9.0.dev-54d3559'

@juliantaylor
Copy link
Contributor

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

@seberg
Copy link
Member

seberg commented Nov 1, 2013

That commit looks like just before the fix was merged.

@rjurney
Copy link

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?

@charris
Copy link
Member

charris commented Nov 1, 2013

What does .git/config show?

@rjurney
Copy link

rjurney commented Nov 1, 2013

@charris
Copy link
Member

charris commented Nov 1, 2013

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

@rjurney
Copy link

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'

@charris
Copy link
Member

charris commented Nov 1, 2013

And what is the first commit shown by git log?

@charris
Copy link
Member

charris commented Nov 1, 2013

It is 0ddb6d19cbddee3fae6a0dc8ba5e1151a0d5f553 here.

@charris
Copy link
Member

charris commented Nov 1, 2013

How are you installing?

@rjurney
Copy link

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?

@charris
Copy link
Member

charris commented Nov 1, 2013

I think it is this one

commit b52487e026fc25e913b226381b185133ea629fc6
Author: Julian Taylor <[email protected]>
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
Copy link
Member

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
Copy link

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?

@juliantaylor
Copy link
Contributor

print numpy

@rjurney
Copy link

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!

@veronicaoleanderhern
Copy link

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

@charris
Copy link
Member

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
Copy link

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 [email protected]:

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//issues/3962#issuecomment-27734713
.

Russell Jurney twitter.com/rjurney [email protected] datasyndrome.com

@charris
Copy link
Member

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.

@veronicaoleanderhern
Copy link

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
Copy link
Member

charris commented Nov 5, 2013

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

@rjurney
Copy link

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 [email protected]:

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


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

Russell Jurney twitter.com/rjurney [email protected] datasyndrome.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants