Closed ogrisel closed 2 years ago
@ogrisel what version of NumPy are you using and how did you install it?
There are some parts of NumPy that are not thread-safe without the GIL. I've patched these in my fork of NumPy and the prebuilt binary wheels include the patches, so if you run pip install numpy
you should get a version that works without the GIL. However, if you're installing from source you should use the version from my fork, such as https://github.com/colesbury/numpy/tree/v1.19.4-nogil or https://github.com/colesbury/numpy/tree/v1.22.3-nogil.
I'm tracking the packages that require changes in the wiki: https://github.com/colesbury/nogil/wiki/Supported-C-API-Extensions
@ogrisel never mind - I'm now able to reproduce the issue with the patched NumPy 1.22.3 (I was previously testing with the patched 1.19.4).
Thanks for the bug report and reproducer.
I've pushed a fix to the nogil NumPy fork and re-built and uploaded the wheels.
You'll need to clear the pip cache because the version number has not changed:
pip uninstall numpy
pip cache purge
pip install numpy
Please let me know if you run into any other multithreading issues with NumPy.
I confirm this fixed the reported bug! Thank you very much for the quick fix.
This might be a bug in numpy that might not be thread-safe when called without the GIL but as I am not sure, here is a report:
Reproducer:
Most of the time, this code segfaults with the following backtrace for the segfaulting thread:
which is a call to
NPY_AUXDATA_FREE(auxdata);
Note that, from time to time, I also observe the following exception before a deadlock: