You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PyBuffer.GetPointer throws exception for N-dimensional buffer #2743
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 commentedon Sep 28, 2026
I can confirm that I also see crashes in this function, but the proposed fix (
fixedandnint*) does not seem to be enough. Will check further.filmor commentedon 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_GetPointeraccessesview->strides, so you must use at leastPyBUF.STRIDESto access it. I will introduce an exception for this onPyBuffer.GetPointer.