From a0d4dafb3cdb86cfa878581b3cbdda8f5526bf13 Mon Sep 17 00:00:00 2001 From: Tian Gao Date: Mon, 15 Jul 2024 13:34:20 -0700 Subject: [PATCH 1/3] Only check f_trace_opcodes if Python frame exists --- Python/legacy_tracing.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From c029bc0109f2e5da05731954f3f318794bc9060d Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Mon, 15 Jul 2024 20:41:09 +0000 Subject: [PATCH 2/3] =?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 --- .../2024-07-15-20-41-06.gh-issue-121814.oR2ixR.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2024-07-15-20-41-06.gh-issue-121814.oR2ixR.rst 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..ee6f01e8b432f2 --- /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 :func:`PyEval_SetTrace` is used with no Python frame on stack. From 4701271a6f2a4a8539ead06c99deabc8e4f37a9e Mon Sep 17 00:00:00 2001 From: Tian Gao Date: Mon, 15 Jul 2024 15:16:49 -0700 Subject: [PATCH 3/3] Update 2024-07-15-20-41-06.gh-issue-121814.oR2ixR.rst --- .../2024-07-15-20-41-06.gh-issue-121814.oR2ixR.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index ee6f01e8b432f2..14666de45f32e3 100644 --- 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 @@ -1 +1 @@ -Fixed the SegFault when :func:`PyEval_SetTrace` is used with no Python frame on stack. +Fixed the SegFault when :c:func:`PyEval_SetTrace` is used with no Python frame on stack.