Ticket #603 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

numpy 1.0.3.1, python crash when indexing an array with a int32 ndarray (see example)

Reported by: djkawa Owned by: jarrod.millman
Priority: normal Milestone: 1.1.0
Component: numpy.core Version: none
Keywords: Cc:

Description

import numpy from numpy import array array = array([0.0], dtype = numpy.float64) index = array([0.0], dtype = numpy.int32) cum_var[index]

array([ 0.])

index = array(0., dtype = numpy.int32) cum_var[index]


Change History

Changed 3 years ago by djkawa

sorry, for wrong formatting of the code example, here is a better one i hope.

>>> import numpy
>>> from numpy import array
>>> an_array = array([0.0], dtype = numpy.float64)
>>> index = array([0.0], dtype = numpy.int32)
>>> an_array[index]
array([ 0.])
>>> index = array(0., dtype = numpy.int32)
>>> an_array[index]

--> CRASH

Changed 3 years ago by jarrod.millman

  • owner changed from somebody to jarrod.millman
  • status changed from new to assigned

It seems to work with the current development version:

>>> import numpy;numpy.version.version
'1.0.4.dev4326'
>>> from numpy import array
>>> an_array = array([0.0], dtype = numpy.float64)
>>> index = array([0.0], dtype = numpy.int32)
>>> an_array[index]
array([ 0.])
>>> index = array(0., dtype = numpy.int32)
>>> an_array[index]
0.0

Changed 3 years ago by djkawa

it still crashes for me with released version numpy 1.0.4 but i guess that your version is after the released version.

(i use numpy as an extracted egg by the way - so shouldn't make any differences)

and python 2.4.4.

Changed 3 years ago by stefan

Still crashes on r4466.

==27113== Invalid read of size 4
==27113==    at 0x487679D: array_subscript_nice (arrayobject.c:3066)
==27113==    by 0x80C5779: PyEval_EvalFrameEx (in /usr/bin/python2.5)
==27113==    by 0x80CA114: PyEval_EvalCodeEx (in /usr/bin/python2.5)
==27113==    by 0x80CA186: PyEval_EvalCode (in /usr/bin/python2.5)
==27113==    by 0x80E9697: PyRun_FileExFlags (in /usr/bin/python2.5)
==27113==    by 0x80E9926: PyRun_SimpleFileExFlags (in /usr/bin/python2.5)
==27113==    by 0x805938F: Py_Main (in /usr/bin/python2.5)
==27113==    by 0x80588C1: main (in /usr/bin/python2.5)
==27113==  Address 0x466B444 is 12 bytes after a block of size 16 alloc'd
==27113==    at 0x4022765: malloc (vg_replace_malloc.c:149)
==27113==    by 0x4841049: gentype_alloc (scalartypes.inc.src:357)
==27113==    by 0x485601B: PyArray_Scalar (arrayobject.c:1341)
==27113==    by 0x4873E0E: iter_subscript (arrayobject.c:9142)
==27113==    by 0x4875AB4: array_subscript (arrayobject.c:2763)
==27113==    by 0x48766A5: array_subscript_nice (arrayobject.c:3030)
==27113==    by 0x80C5779: PyEval_EvalFrameEx (in /usr/bin/python2.5)
==27113==    by 0x80CA114: PyEval_EvalCodeEx (in /usr/bin/python2.5)
==27113==    by 0x80CA186: PyEval_EvalCode (in /usr/bin/python2.5)
==27113==    by 0x80E9697: PyRun_FileExFlags (in /usr/bin/python2.5)

Changed 3 years ago by stefan

Very strange, but if the first element of 'array' is anything other than 0.0, the problem doesn't occur.

Changed 3 years ago by stefan

  • status changed from assigned to closed
  • resolution set to fixed

Closed in r4467.

Note: See TracTickets for help on using tickets.