[Python-checkins] [3.11] GH-91742: Fix pdb crash after jump (GH-94171) (#94176)

pablogsal webhook-mailer at python.org
Thu Jun 23 12:36:05 EDT 2022


https://github.com/python/cpython/commit/1f00e8c55ec449641f6c45cf5cdc382af1f68ada
commit: 1f00e8c55ec449641f6c45cf5cdc382af1f68ada
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: pablogsal <Pablogsal at gmail.com>
date: 2022-06-23T17:36:00+01:00
summary:

[3.11] GH-91742: Fix pdb crash after jump  (GH-94171) (#94176)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303 at users.noreply.github.com>

files:
A Misc/NEWS.d/next/Library/2022-06-23-13-12-05.gh-issue-91742.sNytVX.rst
M Lib/test/test_pdb.py
M Objects/frameobject.c

diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index 0141b739c2544..f0c15e7b9c536 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -1363,7 +1363,50 @@ def test_pdb_issue_43318():
     4
     """
 
+def test_pdb_issue_gh_91742():
+    """See GH-91742
 
+    >>> def test_function():
+    ...    __author__ = "pi"
+    ...    __version__ = "3.14"
+    ...
+    ...    def about():
+    ...        '''About'''
+    ...        print(f"Author: {__author__!r}",
+    ...            f"Version: {__version__!r}",
+    ...            sep=" ")
+    ...
+    ...    import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
+    ...    about()
+
+
+    >>> reset_Breakpoint()
+    >>> with PdbTestInput([  # doctest: +NORMALIZE_WHITESPACE
+    ...     'step',
+    ...     'next',
+    ...     'next',
+    ...     'jump 5',
+    ...     'continue'
+    ... ]):
+    ...     test_function()
+    > <doctest test.test_pdb.test_pdb_issue_gh_91742[0]>(12)test_function()
+    -> about()
+    (Pdb) step
+    --Call--
+    > <doctest test.test_pdb.test_pdb_issue_gh_91742[0]>(5)about()
+    -> def about():
+    (Pdb) next
+    > <doctest test.test_pdb.test_pdb_issue_gh_91742[0]>(7)about()
+    -> print(f"Author: {__author__!r}",
+    (Pdb) next
+    > <doctest test.test_pdb.test_pdb_issue_gh_91742[0]>(8)about()
+    -> f"Version: {__version__!r}",
+    (Pdb) jump 5
+    > <doctest test.test_pdb.test_pdb_issue_gh_91742[0]>(5)about()
+    -> def about():
+    (Pdb) continue
+    Author: 'pi' Version: '3.14'
+    """
 @support.requires_subprocess()
 class PdbTestCase(unittest.TestCase):
     def tearDown(self):
diff --git a/Misc/NEWS.d/next/Library/2022-06-23-13-12-05.gh-issue-91742.sNytVX.rst b/Misc/NEWS.d/next/Library/2022-06-23-13-12-05.gh-issue-91742.sNytVX.rst
new file mode 100644
index 0000000000000..30c92363b10b3
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-06-23-13-12-05.gh-issue-91742.sNytVX.rst
@@ -0,0 +1 @@
+Fix :mod:`pdb` crash after jump caused by a null pointer dereference. Patch by Kumar Aditya.
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 56c4fceb6b893..8be41d4ae06c3 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -418,7 +418,7 @@ static void
 frame_stack_pop(PyFrameObject *f)
 {
     PyObject *v = _PyFrame_StackPop(f->f_frame);
-    Py_DECREF(v);
+    Py_XDECREF(v);
 }
 
 static PyFrameState



More information about the Python-checkins mailing list