-
-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Description
Describe the issue:
Calling PyDataMem_GetHandler()
results in a segmentation fault.
Reproduce the code example:
See repo https://github.com/lorentzenchr/repo_numpy_mem_handler as a minimal reproducer.
The gist of it is that the C function
static inline void
c_get_current_handler()
{
PyObject* handler = PyDataMem_GetHandler();
};
is wrapped by Cython and then called for in a Python test. This results in the segfault.
Error message:
Extension modules: numpy._core._multiarray_umath, numpy.linalg._umath_linalg, numpy_mem_handler (total: 3)
zsh: segmentation fault pytest tests/test_numpy_mem_handler.py
Python and NumPy Versions:
Python 3.13.5
"numpy==2.3.0"
"Cython==3.1.3",
"pytest",
"meson==1.8.3",
"meson-python>=0.16.0",
"ninja==1.13.0",
Runtime Environment:
WARNING: threadpoolctl
not found in system! Install it by pip install threadpoolctl
. Once installed, try np.show_runtime
again for more detailed build information
[{'numpy_version': '2.3.0',
'python': '3.13.5 (main, Jun 11 2025, 15:36:57) [Clang 17.0.0 '
'(clang-1700.0.13.3)]',
'uname': uname_result(system='Darwin', node='MacBookPro.fritz.box', release='24.6.0', version='Darwin Kernel Version 24.6.0: Mon Jul 14 11:28:17 PDT 2025; root:xnu-11417.140.69~1/RELEASE_X86_64', machine='x86_64')},
{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2'],
'not_found': ['AVX512F',
'AVX512CD',
'AVX512_KNL',
'AVX512_SKX',
'AVX512_CLX',
'AVX512_CNL',
'AVX512_ICL']}}]
Context for the issue:
In scikit-learn PR#29846 I wanted to play with aligned memory allocations for the histograms of gradient boosting. Interestingly, the segfault shows up on different platforms/setups in CD.