Skip to content

BUG: Guarantee array is in valid state after memory error occurs in getset.c#15930

Merged
charris merged 1 commit into
numpy:maintenance/1.18.xfrom
charris:backport-15736
Apr 7, 2020
Merged

BUG: Guarantee array is in valid state after memory error occurs in getset.c#15930
charris merged 1 commit into
numpy:maintenance/1.18.xfrom
charris:backport-15736

Conversation

@charris
Copy link
Copy Markdown
Member

@charris charris commented Apr 7, 2020

Backport of #15736.

Currently, in function array_shape_set, ndarray's pointers to dimensions
and strides are freed before new array is allocated (Line 71). In case
memory error occur, the array is left with dangling pointers. Therefore,
we can not recover from such error.

  • To guarantee array in valid state when memory error occur
  • Fix: Free cache when nd == 0 to avoid memory leak
  • Update numpy/core/src/multiarray/getset.c
    Co-Authored-By: Eric Wieser wieser.eric@gmail.com

…etset.c

Currently, in function array_shape_set, ndarray's pointers to dimensions
and strides are freed before new array is allocated (Line 71). In case
memory error occur, the array is left with dangling pointers. Therefore,
we can not recover from such error.

* To guarantee array in valid state when memory error occur
* Fix: Free cache when nd == 0 to avoid memory leak
* Update numpy/core/src/multiarray/getset.c
Co-Authored-By: Eric Wieser <wieser.eric@gmail.com>
@charris charris added this to the 1.18.3 release milestone Apr 7, 2020
@charris charris merged commit a7594bd into numpy:maintenance/1.18.x Apr 7, 2020
@charris charris deleted the backport-15736 branch April 7, 2020 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants