https://github.com/python/cpython/commit/54db42fe2ca6b6cbbed84499627064367869e6cb
commit: 54db42fe2ca6b6cbbed84499627064367869e6cb
branch: 3.13
author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com>
committer: gaogaotiantian <gaogaotiant...@hotmail.com>
date: 2024-07-16T10:13:28-07:00
summary:

[3.13] gh-121814: Only check f_trace_opcodes if Python frame exists (GH-121818) 
(#121861)

gh-121814: Only check f_trace_opcodes if Python frame exists (GH-121818)
(cherry picked from commit 2b1b68939b15b913080a3403e3ba18e2a1f520ef)

Co-authored-by: Tian Gao <gaogaotiant...@hotmail.com>
Co-authored-by: Matt Wozniski <godlyg...@gmail.com>

files:
A Misc/NEWS.d/next/Core and 
Builtins/2024-07-15-20-41-06.gh-issue-121814.oR2ixR.rst
M Python/legacy_tracing.c

diff --git a/Misc/NEWS.d/next/Core and 
Builtins/2024-07-15-20-41-06.gh-issue-121814.oR2ixR.rst b/Misc/NEWS.d/next/Core 
and Builtins/2024-07-15-20-41-06.gh-issue-121814.oR2ixR.rst
new file mode 100644
index 00000000000000..14666de45f32e3
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and 
Builtins/2024-07-15-20-41-06.gh-issue-121814.oR2ixR.rst 
@@ -0,0 +1 @@
+Fixed the SegFault when :c:func:`PyEval_SetTrace` is used with no Python frame 
on stack.
diff --git a/Python/legacy_tracing.c b/Python/legacy_tracing.c
index 74118030925e3e..1103d999dfaea5 100644
--- a/Python/legacy_tracing.c
+++ b/Python/legacy_tracing.c
@@ -605,7 +605,7 @@ _PyEval_SetTrace(PyThreadState *tstate, Py_tracefunc func, 
PyObject *arg)
             (1 << PY_MONITORING_EVENT_STOP_ITERATION);
 
         PyFrameObject* frame = PyEval_GetFrame();
-        if (frame->f_trace_opcodes) {
+        if (frame && frame->f_trace_opcodes) {
             int ret = _PyEval_SetOpcodeTrace(frame, true);
             if (ret != 0) {
                 return ret;

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to