Closed
Description
Expected behaviour
Numpy array has a flag indicating if the array is writeable or not.
In the case it is not writeable and the user is trying to write on the array, I would imagine opencv would raise an issue or would use a copy.
Actual behaviour
Opencv write on the array without checking the flag that can raise a segmentation fault.
Steps to reproduce
The following example is a simple example taken from https://github.com/dora-rs/dora , which use the latest pyarrow. You can probably make a numpy only example.
import pyarrow as pa
import numpy as np
import cv2
array = pa.array(np.zeros((100))).to_numpy().reshape((10,10))
assert array.flags.writeable == False, "Array should be not writable"
cv2.rectangle(array,(0,0),(5,5),(255),2)
print(array)
array([[255., 255., 255., 255., 255., 255., 255., 0., 0., 0.],
[255., 255., 255., 255., 255., 255., 255., 0., 0., 0.],
[255., 255., 0., 0., 255., 255., 255., 0., 0., 0.],
[255., 255., 0., 0., 255., 255., 255., 0., 0., 0.],
[255., 255., 255., 255., 255., 255., 255., 0., 0., 0.],
[255., 255., 255., 255., 255., 255., 255., 0., 0., 0.],
[255., 255., 255., 255., 255., 255., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]])
Errors
This can lead to segmentation fault error if the data is not owned by the current process.
I wonder if #728 is linked to this issue.
Metadata
Metadata
Assignees
Labels
No labels