Missing range check for negative index parameter in oneflow.scatter. When index as a positive number exceeds the range of size, core dumped occurs, and when index as a negative number exceeds the range of size, no error is reported.
Code to reproduce bug
import oneflow as flow
import numpy as np
input = flow.ones((3,5))*2
index = flow.tensor(np.array([[0,-10000,2],[0,1,4]], ), dtype=flow.int32)
src = flow.Tensor(np.array([[0,10,20,30,40],[50,60,70,80,90]]))
out = flow.scatter(input, 1, index, src)
print(out)
import oneflow as flow
import numpy as np
input = flow.ones((3,5))*2
index = flow.tensor(np.array([[0,10000,2],[0,1,4]], ), dtype=flow.int32)
src = flow.Tensor(np.array([[0,10,20,30,40],[50,60,70,80,90]]))
out = flow.scatter(input, 1, index, src)
print(out)
the core dumped will last more than 10 secs.
System Information
What is your OneFlow installation :dockerhub
OS:Linux
OneFlow version (run python3 -m oneflow --doctor):0.9.1.dev20231024+cu117
Summary
Missing range check for negative index parameter in oneflow.scatter. When index as a positive number exceeds the range of size, core dumped occurs, and when index as a negative number exceeds the range of size, no error is reported.
Code to reproduce bug
System Information