]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-121814: Only check f_trace_opcodes if Python frame exists (GH-121818) ...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 16 Jul 2024 17:13:28 +0000 (19:13 +0200)
committerGitHub <noreply@github.com>
Tue, 16 Jul 2024 17:13:28 +0000 (10:13 -0700)
gh-121814: Only check f_trace_opcodes if Python frame exists (GH-121818)
(cherry picked from commit 2b1b68939b15b913080a3403e3ba18e2a1f520ef)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
Co-authored-by: Matt Wozniski <godlygeek@gmail.com>
Misc/NEWS.d/next/Core and Builtins/2024-07-15-20-41-06.gh-issue-121814.oR2ixR.rst [new file with mode: 0644]
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 (file)
index 0000000..14666de
--- /dev/null
@@ -0,0 +1 @@
+Fixed the SegFault when :c:func:`PyEval_SetTrace` is used with no Python frame on stack.
index 74118030925e3e0816e7c39fa89c28139bb4cb50..1103d999dfaea5911d6c9ed5fe6bc8dbe1edba7a 100644 (file)
@@ -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;