From 7fced44d7b6acd0ffee1b2b7d03a13a1658bfafd Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Tue, 16 Dec 2025 23:12:16 +0000 Subject: [PATCH 1/4] Mark tracer function as Py_NO_INLINE --- Python/optimizer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/optimizer.c b/Python/optimizer.c index b215e43128fa2c..2052010954535e 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -582,7 +582,7 @@ is_terminator(const _PyUOpInstruction *uop) /* Returns 1 on success (added to trace), 0 on trace end. */ -int +Py_NO_INLINE int _PyJit_translate_single_bytecode_to_trace( PyThreadState *tstate, _PyInterpreterFrame *frame, From 8f854b8c1ab2af9d447dcafe112324bd01581367 Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Tue, 16 Dec 2025 23:18:33 +0000 Subject: [PATCH 2/4] mark more things as noinline --- Python/optimizer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/optimizer.c b/Python/optimizer.c index 2052010954535e..6dfcc9ba0dfee0 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -994,7 +994,7 @@ _PyJit_translate_single_bytecode_to_trace( } // Returns 0 for do not enter tracing, 1 on enter tracing. -int +Py_NO_INLINE int _PyJit_TryInitializeTracing( PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *curr_instr, _Py_CODEUNIT *start_instr, _Py_CODEUNIT *close_loop_instr, int curr_stackdepth, int chain_depth, From 87ceff2053a59be907d5babe94459fa504236e56 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Tue, 16 Dec 2025 23:26:49 +0000 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2025-12-16-23-26-41.gh-issue-142543.wJKjBs.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2025-12-16-23-26-41.gh-issue-142543.wJKjBs.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-12-16-23-26-41.gh-issue-142543.wJKjBs.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-12-16-23-26-41.gh-issue-142543.wJKjBs.rst new file mode 100644 index 00000000000000..0897127fec747e --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-12-16-23-26-41.gh-issue-142543.wJKjBs.rst @@ -0,0 +1 @@ +Fix a stack overflow on Clang JIT build configurations with full LTO. From 8ff4a63695542f39a383efd463bfa8b6e55741b7 Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Tue, 16 Dec 2025 23:37:38 +0000 Subject: [PATCH 4/4] add comments --- Python/optimizer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Python/optimizer.c b/Python/optimizer.c index 6dfcc9ba0dfee0..18f54f9bc23476 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -582,6 +582,7 @@ is_terminator(const _PyUOpInstruction *uop) /* Returns 1 on success (added to trace), 0 on trace end. */ +// gh-142543: inlining this function causes stack overflows Py_NO_INLINE int _PyJit_translate_single_bytecode_to_trace( PyThreadState *tstate, @@ -994,6 +995,7 @@ _PyJit_translate_single_bytecode_to_trace( } // Returns 0 for do not enter tracing, 1 on enter tracing. +// gh-142543: inlining this function causes stack overflows Py_NO_INLINE int _PyJit_TryInitializeTracing( PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *curr_instr, @@ -1066,7 +1068,7 @@ _PyJit_TryInitializeTracing( return 1; } -void +Py_NO_INLINE void _PyJit_FinalizeTracing(PyThreadState *tstate) { _PyThreadStateImpl *_tstate = (_PyThreadStateImpl *)tstate;