Disable "Move Subinterpreter" test on free-threaded Python 3.14+

This test hangs in Py_EndInterpreter() when the subinterpreter is
destroyed from a different thread than it was created on.

The hang was observed:
- Intermittently on macOS with Python 3.14.0t
- Predictably on macOS, Ubuntu, and Windows with Python 3.14.1t and 3.14.2t

Root cause analysis points to an interaction between pybind11's
subinterpreter creation code and CPython's free-threaded runtime,
specifically around PyThreadState_Swap() after PyThreadState_DeleteCurrent().

See detailed analysis: https://github.com/pybind/pybind11/pull/5933
This commit is contained in:
Ralf W. Grosse-Kunstleve
2025-12-20 18:59:44 -08:00
parent 21d0dc5e59
commit e1b1b1bdd6

View File

@@ -90,7 +90,11 @@ TEST_CASE("Single Subinterpreter") {
unsafe_reset_internals_for_single_interpreter();
}
# if PY_VERSION_HEX >= 0x030D0000
// "Move Subinterpreter" test is disabled on free-threaded Python 3.14+ due to a hang
// in Py_EndInterpreter() when the subinterpreter is destroyed from a different thread
// than it was created on. See: https://github.com/pybind/pybind11/pull/5933
# if PY_VERSION_HEX >= 0x030D0000 \
&& !(PY_VERSION_HEX >= 0x030E0000 && defined(Py_GIL_DISABLED))
TEST_CASE("Move Subinterpreter") {
std::unique_ptr<py::subinterpreter> sub(new py::subinterpreter(py::subinterpreter::create()));