Segmentation Fault with numpy `1.25.2` arrays when using conversion methods
Checklist
- [X] I have searched for similar issues.
- [x] For Python issues, I have tested with the latest development wheel.
- [X] I have checked the release documentation and the latest documentation (for
mainbranch).
Describe the issue
Using the latest dev version, build from source, I have a segmentation fault when using open3d.utility.IntVector with a numpy array.
I am not using numpy 2.0.0, so it is probably unrelated to other issues being described.
Steps to reproduce the bug
import numpy as np
from open3d.utility import IntVector
# this works
IntVector([0, 0, 0])
# this leads to segfault
IntVector(np.array([0, 0, 0]))
Error message
Fatal Python error: Segmentation fault
Main thread:
Current thread 0x000072d01d497000 (most recent call first):
File "/tmp/ipykernel_73644/2190508328.py", line 1 in
Restarting kernel...
Expected behavior
No response
Open3D, Python and System information
- Operating system: Ubuntu 20.04
- Python version: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
- Open3D version: 0.18.0+fcf98ee45
- System architecture: x86
- Is this a remote workstation?: no
- How did you install Open3D?: build from source
- Compiler version (if built from source): gcc 11.4.0
Additional information
DoubleVector, for example, works:
import numpy as np
from open3d.utility import DoubleVector
DoubleVector(np.array([0, 0, 0.5]))
So it might be a problem with IntVector.
I don't see a seg fault, just a type error: (numpy v1.26)
>>> IntVector(np.array([0, 0, 0]))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Format mismatch (Python: l C++: i)
This works:
>>> IntVector(np.array([0, 0, 0], dtype=np.int32))
IntVector[0, 0, 0]
Please use the prebuilt wheels - there may be some issue in your environment.
It didn't give me type errors in the past though, curiously.
And thank you for the input, but I actually need the development version to use a recent PR that was made.
We build wheels for every push to the main branch. Maybe this can help https://github.com/isl-org/Open3D/actions/runs/9978177970
Sorry for the delay. I installed from this wheel: open3d-0.18.0+553ca86-cp310-cp310-manylinux_2_31_x86_64.whl, import open3d and calling open3d.__version__ gives '0.18.0+553ca86' so it should be ok.
I still have a segfault running IntVector(np.array([0, 0, 0])) though. I also realized other things give segfaults, maybe everytime I have an error.
For example, running TriangleMesh.create_from_point_cloud_alpha_shape(pointcloud, 0.0) is giving me a segfault too.