From e1b1b1bdd6519bbdfb1d5bcb4669b97fd8cab4dd Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sat, 20 Dec 2025 18:59:44 -0800 Subject: [PATCH] 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 --- tests/test_with_catch/test_subinterpreter.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_with_catch/test_subinterpreter.cpp b/tests/test_with_catch/test_subinterpreter.cpp index 3c7c35be1..8f30c8f44 100644 --- a/tests/test_with_catch/test_subinterpreter.cpp +++ b/tests/test_with_catch/test_subinterpreter.cpp @@ -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 sub(new py::subinterpreter(py::subinterpreter::create()));