PyBuffer.GetPointer throws System.ExecutionEngineException when called with an N-dimensional array obtained with PyBUF.ND flag.
dynamicnp=Py.Import("numpy");// create 3D NumPy arrayint[]shape=[10,10,10];PyObjectndArray=np.zeros(shape);PyBufferbuf=ndArray.GetBuffer(PyBUF.ND);// this throws System.ExecutionEngineExceptionnintptr=buf.GetPointer([0,0,0]);
I suspect that this may be caused by a mismatch of a type. The following code seems to pass a CLR array to native function pointer.
PyObject_GetPointer accesses view->strides, so you must use at least PyBUF.STRIDES to access it. I will introduce an exception for this on PyBuffer.GetPointer.
Activity
filmor commented on Sep 28, 2026
I can confirm that I also see crashes in this function, but the proposed fix (fixed and nint*) does not seem to be enough. Will check further.
filmor commented on Sep 28, 2026
I can't find any useful docs on this, but the issue is PyBUF.ND:
https://github.com/python/cpython/blob/9e9c3c49b4a41eebb982891c3ccdc17ae5ab9963/Objects/abstract.c#L544-L557
PyObject_GetPointer accesses view->strides, so you must use at least PyBUF.STRIDES to access it. I will introduce an exception for this on PyBuffer.GetPointer.