Skip to content

Commit 54db42f

Browse files
miss-islingtongaogaotiantiangodlygeek
authored
[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 2b1b689) Co-authored-by: Tian Gao <[email protected]> Co-authored-by: Matt Wozniski <[email protected]>
1 parent c11d789 commit 54db42f

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed the SegFault when :c:func:`PyEval_SetTrace` is used with no Python frame on stack.

Python/legacy_tracing.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ _PyEval_SetTrace(PyThreadState *tstate, Py_tracefunc func, PyObject *arg)
605605
(1 << PY_MONITORING_EVENT_STOP_ITERATION);
606606

607607
PyFrameObject* frame = PyEval_GetFrame();
608-
if (frame->f_trace_opcodes) {
608+
if (frame && frame->f_trace_opcodes) {
609609
int ret = _PyEval_SetOpcodeTrace(frame, true);
610610
if (ret != 0) {
611611
return ret;

0 commit comments

Comments
 (0)