diplib: Importing pyfftw and diplib in the same process can lead to segfaults
Component PyDIP 3.4.0.
Describe the bug Importing pyfftw and diplib in the same process, and having diplib try to access its own internal fftw library, can lead to segfaults.
To Reproduce
$ python -c 'import pyfftw, numpy as np, diplib as dip; dip.GaussFT(np.zeros((139, 217)), 3, [1, 1])'
Fatal Python error: Segmentation fault
(the array size above is just some awkward numbers to trigger the use of fftw)
System information:
- What OS do you have? macSO 13.4.1
- If PyDIP, what version of Python do you have? 3.11
- If DIPimage, what version of MATLAB do you have? (type
ver
at the MATLAB command prompt, and copy-paste the result here). N/A - If compiled from sources, what compiler and version did you use? N/A
Note: pyFFTW was installed from their git HEAD (pip install git+https://github.com/pyFFTW/pyFFTW
) as their latest release does not support py3.11 AFAICT.
I suspect we end up with two copies of fftw with incompatible ABIs which step onto another…
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 19 (18 by maintainers)
Links to this issue
Commits related to this issue
- Added note regarding vendored OpenMP to the PyPI README file. See #130. — committed to DIPlib/diplib by crisluengo a year ago
(I am on macos 13.4.1.) Indeed, building pyfftw with PYFFTW_USE_PTHREADS (pthreads instead of openmp) fixes the issue. https://pypackaging-native.github.io/key-issues/native-dependencies/blas_openmp/ looks like an interesting read; I guess there isn’t really any solution except perhaps for diplib to also provide an option (not necessarily to change the default) to be built without openmp either.