]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-121814: Only check f_trace_opcodes if Python frame exists (#121818)
authorTian Gao <gaogaotiantian@hotmail.com>
Mon, 15 Jul 2024 23:11:02 +0000 (16:11 -0700)
committerGitHub <noreply@github.com>
Mon, 15 Jul 2024 23:11:02 +0000 (16:11 -0700)
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;