[Numpy-discussion] Segfault for np.lookfor
Matthew Brett
matthew.brett at gmail.com
Tue Aug 16 15:15:22 EDT 2011
Hi,
On Tue, Aug 16, 2011 at 10:05 AM, Charles R Harris
<charlesr.harris at gmail.com> wrote:
>
>
> On Mon, Aug 15, 2011 at 7:43 PM, Charles R Harris
> <charlesr.harris at gmail.com> wrote:
>>
>>
>> On Mon, Aug 15, 2011 at 7:09 PM, Charles R Harris
>> <charlesr.harris at gmail.com> wrote:
>>>
>>>
>>> On Mon, Aug 15, 2011 at 6:56 PM, Charles R Harris
>>> <charlesr.harris at gmail.com> wrote:
>>>>
>>>>
>>>> On Mon, Aug 15, 2011 at 3:53 PM, Matthew Brett <matthew.brett at gmail.com>
>>>> wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> On current trunk, all tests pass but running the (forgive my language)
>>>>> doctests, I found this:
>>>>>
>>>>> In [1]: import numpy as np
>>>>>
>>>>> In [2]: np.__version__
>>>>> Out[2]: '2.0.0.dev-730b861'
>>>>>
>>>>> In [3]: np.lookfor('cos')
>>>>> Segmentation fault
>>>>>
>>>>> on:
>>>>>
>>>>> Linux angela 2.6.38-10-generic #46-Ubuntu SMP Tue Jun 28 15:07:17 UTC
>>>>> 2011 x86_64 x86_64 x86_64 GNU/Linux
>>>>> Ubuntu Natty Python 2.7.1+
>>>>>
>>>>
>>>> The problem is somewhere in print_coercion_tables.py
>>>>
>>>
>>> Or more precisely, it triggered by importing print_coercion_tables.py. I
>>> don't think lookfor should be doing that, but in any case:
>>>
>>> array + scalar
>>> + ? b h i l q p B H I L Q P e f d g F D G S U V O M m
>>> ? ? b h i l l l B H I L L L e f d g F D G O O # O ! m
>>> b b b b b b b b b b b b b b e f d g F D G O O # O ! m
>>> h h h h h h h h h h h h h h f f d g F D G O O # O ! m
>>> i i i i i i i i i i i i i i d d d g D D G O O # O ! m
>>> l l l l l l l l l l l l l l d d d g D D G O O # O ! m
>>> q l l l l l l l l l l l l l d d d g D D G O O # O ! m
>>> p l l l l l l l l l l l l l d d d g D D G O O # O ! m
>>> B B B B B B B B B B B B B B e f d g F D G O O # O ! m
>>> H H H H H H H H H H H H H H f f d g F D G O O # O ! m
>>> I I I I I I I I I I I I I I d d d g D D G O O # O ! m
>>> L L L L L L L L L L L L L L d d d g D D G O O # O ! m
>>> Q L L L L L L L L L L L L L d d d g D D G O O # O ! m
>>> P L L L L L L L L L L L L L d d d g D D G O O # O ! m
>>> e e e e e e e e e e e e e e e e e e F F F O O # O ! #
>>> f f f f f f f f f f f f f f f f f f F F F O O # O ! #
>>> d d d d d d d d d d d d d d d d d d D D D O O # O ! #
>>> g g g g g g g g g g g g g g g g g g G G G O O # O ! #
>>> F F F F F F F F F F F F F F F F F F F F F O O # O ! #
>>> D D D D D D D D D D D D D D D D D D D D D O O # O ! #
>>> G G G G G G G G G G G G G G G G G G G G G O O # O ! #
>>> S O O O O O O O O O O O O O O O O O O O O O O # O ! O
>>> U O O O O O O O O O O O O O O O O O O O O O O # O ! O
>>> Segmentation fault (core dumped)
>>
>> A quick fix is to put the print statements in a function.
>>
>> diff --git a/numpy/testing/print_coercion_tables.py
>> b/numpy/testing/print_coercion_tables.p
>> index d875449..3bc9253 100755
>> --- a/numpy/testing/print_coercion_tables.py
>> +++ b/numpy/testing/print_coercion_tables.py
>> @@ -65,22 +65,23 @@ def print_coercion_table(ntypes, inputfirstvalue,
>> inputsecondvalue, fir
>> print char,
>> print
>>
>> -print "can cast"
>> -print_cancast_table(np.typecodes['All'])
>> -print
>> -print "In these tables, ValueError is '!', OverflowError is '@',
>> TypeError is '#'"
>> -print
>> -print "scalar + scalar"
>> -print_coercion_table(np.typecodes['All'], 0, 0, False)
>> -print
>> -print "scalar + neg scalar"
>> -print_coercion_table(np.typecodes['All'], 0, -1, False)
>> -print
>> -print "array + scalar"
>> -print_coercion_table(np.typecodes['All'], 0, 0, True)
>> -print
>> -print "array + neg scalar"
>> -print_coercion_table(np.typecodes['All'], 0, -1, True)
>> -print
>> -print "promote_types"
>> -print_coercion_table(np.typecodes['All'], 0, 0, False, True)
>> +def printem():
>> + print "can cast"
>> + print_cancast_table(np.typecodes['All'])
>> + print
>> + print "In these tables, ValueError is '!', OverflowError is '@',
>> TypeError is '#'"
>> + print
>> + print "scalar + scalar"
>> + print_coercion_table(np.typecodes['All'], 0, 0, False)
>> + print
>> + print "scalar + neg scalar"
>> + print_coercion_table(np.typecodes['All'], 0, -1, False)
>> + print
>> + print "array + scalar"
>> + print_coercion_table(np.typecodes['All'], 0, 0, True)
>> + print
>> + print "array + neg scalar"
>> + print_coercion_table(np.typecodes['All'], 0, -1, True)
>> + print
>> + print "promote_types"
>> + print_coercion_table(np.typecodes['All'], 0, 0, False, True)
>>
>
> I opened ticket #1937 for this
>From git-bisect it looks like the culprit is:
feb8079070b8a659d7eee1b4acbddf470fd8a81d is the first bad commit
commit feb8079070b8a659d7eee1b4acbddf470fd8a81d
Author: Ben Walsh <b at wumpster.com>
Date: Sun Jul 10 12:52:52 2011 +0100
BUT: Stop _array_find_type trying to make every list element a
subtype of bool.
Just to remind me, my procedure was:
<~/tmp/testfor.py>
#!/usr/bin/env python
import sys
from functools import partial
from subprocess import check_call, Popen, PIPE, CalledProcessError
caller = partial(check_call, shell=True)
popener = partial(Popen, stdout=PIPE, stderr=PIPE, shell=True)
try:
caller('git clean -fxd')
caller('python setup.py build_ext -i')
except CalledProcessError:
sys.exit(125) # untestable
proc = popener('python -c "%s"' %
"""import sys
import numpy as np
np.lookfor('cos', output=sys.stdout)
""")
stdout, stderr = proc.communicate()
if 'Segmentation fault' in stderr:
sys.exit(1) # bad
sys.exit(0) # good
</~/tmp/testfor.py>
Then, I established the v1.6.1 did not have the segfault, and (man git-bisect):
git co main-master # current upstream master
git bisect start HEAD v1.6.1 --
git bisect run ~/tmp/testfor.py
See y'all,
Matthew
More information about the NumPy-Discussion
mailing list