From 1434444cfa2a2b70b4965887af342cd9c9b81c82 Mon Sep 17 00:00:00 2001 From: Charlie West-Taylor Date: Mon, 14 Nov 2022 10:12:30 +0000 Subject: [PATCH] Use the Python frame safely in _pythonCallstack --- torch/csrc/jit/python/python_tracer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torch/csrc/jit/python/python_tracer.cpp b/torch/csrc/jit/python/python_tracer.cpp index 83570c85e9b4cc2..c89d54872a07bbc 100644 --- a/torch/csrc/jit/python/python_tracer.cpp +++ b/torch/csrc/jit/python/python_tracer.cpp @@ -27,7 +27,7 @@ namespace tracer { std::vector _pythonCallstack() { pybind11::gil_scoped_acquire gil; PyFrameObject* frame = PyEval_GetFrame(); - Py_INCREF(frame); + Py_XINCREF(frame); std::vector entries; while (nullptr != frame) {