thouis / numpy-trac-migration

numpy Trac to github issues migration
2 stars 3 forks source link

concatenate() segfaults on dict_values (Python 3) (migrated from Trac #2019) #3731

Open thouis opened 12 years ago

thouis commented 12 years ago

Original ticket http://projects.scipy.org/numpy/ticket/2019 Reported 2012-01-15 by trac user takluyver, assigned to unknown.

Steps to reproduce:

In [1]: import numpy as np

In [2]: np.__version__
Out[2]: '1.6.1'

In [3]: d = {1:np.ones(5), 2:np.zeros(5)}

In [4]: np.concatenate(d.values())
Segmentation fault

gdb output:

This GDB was configured as "i686-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /home/thomas/Code/virtualenvs/pymc3/bin/python3...(no debugging symbols found)...done.
(gdb) run -c "import numpy as np;d = {1:np.ones(5), 2:np.zeros(5)};np.concatenate(d.values())"
Starting program: /home/thomas/Code/virtualenvs/pymc3/bin/python3 -c "import numpy as np;d = {1:np.ones(5), 2:np.zeros(5)};np.concatenate(d.values())"
[Thread debugging using libthread_db enabled]

Program received signal SIGSEGV, Segmentation fault.
PyArray_ConvertToCommonType (op=0x8aa0584, retn=0xbfffee4c)
    at numpy/core/src/multiarray/convert_datatype.c:1515
1515            if (!PyArray_CheckAnyScalar(otmp)) {
(gdb) c
Continuing.

Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.

This is with Python 3.2.2 on 32-bit Linux. Converting it to a list works fine:

In [3]: np.concatenate(list(d.values()))
Out[3]: array([ 1.,  1.,  1.,  1.,  1.,  0.,  0.,  0.,  0.,  0.])
thouis commented 12 years ago

Comment in Trac by trac user takluyver, 2012-01-15

thouis commented 12 years ago

Comment in Trac by atmention:charris, 2012-04-12

With python 3.2.1 I get an error:

>>> d
{1: array([ 1.,  1.,  1.,  1.,  1.]), 2: array([ 0.,  0.,  0.,  0.,  0.])}
>>> np.concatenate(d.values())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'dict_values' object does not support indexing

So this looks like it might be a Python bug as far as the segfault goes. I don't know that we should support the new dict_values type.

thouis commented 12 years ago

Comment in Trac by atmention:charris, 2012-04-12

Replying to [comment:2 charris]:

With python 3.2.1 I get an error:

{{{

d {1: array([ 1., 1., 1., 1., 1.]), 2: array([ 0., 0., 0., 0., 0.])} np.concatenate(d.values()) Traceback (most recent call last): File "", line 1, in TypeError: 'dict_values' object does not support indexing

}}}

So this looks like it might be a Python bug as far as the segfault goes. I don't know that we should support the new dict_values type.

Oh, and this is with current devel. Could you test that to see if it is still a problem?