Skip to content

Commit 51410d8

Browse files
authored
gh-125217: Turn off optimization around_PyEval_EvalFrameDefault to avoid MSVC crash (#125477)
1 parent bee112a commit 51410d8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Python/ceval.c

+14
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,16 @@ _PyObjectArray_Free(PyObject **array, PyObject **scratch)
761761
* so consume 3 units of C stack */
762762
#define PY_EVAL_C_STACK_UNITS 2
763763

764+
#if defined(_MSC_VER) && defined(_Py_USING_PGO) && defined(_Py_JIT)
765+
/* _PyEval_EvalFrameDefault is too large to optimize for speed with
766+
PGO on MSVC when the JIT is enabled. Disable that optimization
767+
around this function only. If this is fixed upstream, we should
768+
gate this on the version of MSVC.
769+
*/
770+
# pragma optimize("t", off)
771+
/* This setting is reversed below following _PyEval_EvalFrameDefault */
772+
#endif
773+
764774
PyObject* _Py_HOT_FUNCTION
765775
_PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int throwflag)
766776
{
@@ -1136,6 +1146,10 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
11361146

11371147
}
11381148

1149+
#if defined(_MSC_VER) && defined(_Py_USING_PGO) && defined(_Py_JIT)
1150+
# pragma optimize("", on)
1151+
#endif
1152+
11391153
#if defined(__GNUC__)
11401154
# pragma GCC diagnostic pop
11411155
#elif defined(_MSC_VER) /* MS_WINDOWS */

0 commit comments

Comments
 (0)