Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[Bug] Not able to detect out of bound index on an ndarray. potential memory overflow. #12389

Open
yuxiangw opened this issue Aug 29, 2018 · 3 comments

Comments

@yuxiangw
Copy link
Contributor

yuxiangw commented Aug 29, 2018

Minimum reproducible example

from mxnet import ndarray as nd
import numpy as np
# Declare an mxnet ndarray
x = nd.array(range(5))
print(x)

# Try an out of bound index 
idx = [5]
print('mxnet:',x[idx])

Output:

[0. 1. 2. 3. 4.]
<NDArray 5 @cpu(0)>
mxnet: 
[-3.689349e+19]
<NDArray 1 @cpu(0)>

Note that there is no complaint what-so-ever. Not even a warning.

On the other hand, if you do the following instead:

# indexing with integer
idx=5
x[idx]

Then you get the desired error message:

IndexError: index 5 is out of bounds for axis 0 with size 5
@anirudhacharya
Copy link
Member

@mxnet-label-bot [NDArray, Memory, Bug]

@samskalicky
Copy link
Contributor

@marcoabreu please remove Memory label, this is a bug in NDArray API.

@mseth10
Copy link
Contributor

mseth10 commented Feb 5, 2019

@mxnet-label-bot remove [Memory]

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants