Conversation
|
I confirm this PR addresses the bug. |
|
It looks like some test is stalled with this PR. Any hint? |
|
All stall processes are when testing 3.14t, i.e. the free-threaded version. |
|
I reproduced the stall locally on Python 3.14t with the CI test command. The new regression test passed on its own, but under |
|
Apparently the fact the tests dead-lock in thread-free version of python is a different issue related to the I can propose some locking to protect this function if needed, but maybe @xuu33030 prefers doing it on his own. |
|
Thanks for offering, @kif. Would you like to take the |
|
I think I will submit a separated PR ... maybe even open another issue since what we see here is just highlighting an issue already pre-existing. |
Summary
NumExprobject with a per-object lockProblem
A compiled
NumExprobject stores mutable execution buffers on the object. When the same object is called concurrently whileNUMEXPR_NUM_THREADS=1, multiple Python threads can enter the serial interpreter path at once and overwrite that shared state, causing incorrect results or heap corruption.The existing global
parallel_mutexonly protects the multi-threaded interpreter path and therefore does not cover this case.Verification
SIGABRTon macOS arm64 / Python 3.13 / NumPy 2.5.3.python -m pytest numexpr/tests/test_numexpr.py::test_threading::test_shared_compiled_expression -q— 1 passedpython -m pytest -q— 6043 passedNUMEXPR_NUM_THREADS=1— printsOKgit diff --check— cleanCloses #569