Skip to content

Python segfaults when printing array in IPython #3962

@beojan

Description

@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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions