public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
To: git-commits@fedoraproject.org
Subject: [rpms/gdb] gdb-17.2-rebase-f44: Backport upstream commits 7ae9ecfd801 and 8170efad364 to avoid
Date: Sun, 28 Jun 2026 00:01:27 GMT	[thread overview]
Message-ID: <178260488707.1.12067086097576186225.rpms-gdb-9b9015292196@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/gdb
            Branch : gdb-17.2-rebase-f44
            Commit : 9b9015292196a4a680781376c68d224b63eca163
            Author : Alexandra Hájková <ahajkova@redhat.com>
            Date   : 2024-01-09T13:41:13+01:00
            Stats  : +144/-1 in 6 file(s)
            URL    : https://src.fedoraproject.org/rpms/gdb/c/9b9015292196a4a680781376c68d224b63eca163?branch=gdb-17.2-rebase-f44

            Log:
            Backport upstream commits 7ae9ecfd801 and 8170efad364 to avoid

using _PyOS_ReadlineTState  (RHBZ 2250652).

---
diff --git a/_gdb.spec.Patch.include b/_gdb.spec.Patch.include
index 9b964ed..87c2ab7 100644
--- a/_gdb.spec.Patch.include
+++ b/_gdb.spec.Patch.include
@@ -187,3 +187,9 @@ Patch042: gdb-rhbz-2232086-generate-gdb-index-consistently.patch
 # non-deterministic gdb-index generation (RH BZ 2232086).
 Patch043: gdb-rhbz-2232086-generate-dwarf-5-index-consistently.patch
 
+
+Patch044: gdb-rhbz2250652-gdbpy_gil.patch
+
+
+Patch045: gdb-rhbz2250652-avoid-PyOS_ReadlineTState.patch
+

diff --git a/_gdb.spec.patch.include b/_gdb.spec.patch.include
index abd8ca2..cfd9510 100644
--- a/_gdb.spec.patch.include
+++ b/_gdb.spec.patch.include
@@ -41,3 +41,5 @@
 %patch -p1 -P041
 %patch -p1 -P042
 %patch -p1 -P043
+%patch -p1 -P044
+%patch -p1 -P045

diff --git a/_patch_order b/_patch_order
index aee01ee..7c373f2 100644
--- a/_patch_order
+++ b/_patch_order
@@ -41,3 +41,5 @@ gdb-rhbz-2232086-reduce-size-of-gdb-index.patch
 gdb-rhbz-2232086-cpp-ify-mapped-symtab.patch
 gdb-rhbz-2232086-generate-gdb-index-consistently.patch
 gdb-rhbz-2232086-generate-dwarf-5-index-consistently.patch
+gdb-rhbz2250652-gdbpy_gil.patch
+gdb-rhbz2250652-avoid-PyOS_ReadlineTState.patch

diff --git a/gdb-rhbz2250652-avoid-PyOS_ReadlineTState.patch b/gdb-rhbz2250652-avoid-PyOS_ReadlineTState.patch
new file mode 100644
index 0000000..1997ef9
--- /dev/null
+++ b/gdb-rhbz2250652-avoid-PyOS_ReadlineTState.patch
@@ -0,0 +1,48 @@
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= <ahajkova@redhat.com>
+Date: Mon, 8 Jan 2024 13:24:05 +0100
+Subject: gdb-rhbz2250652-avoid-PyOS_ReadlineTState.patch
+
+gdb/python: avoid use of _PyOS_ReadlineTState
+
+In python/py-gdb-readline.c we make use of _PyOS_ReadlineTState,
+however, this variable is no longer public in Python 3.13, and so GDB
+no longer builds.
+
+We are making use of _PyOS_ReadlineTState in order to re-acquire the
+Python Global Interpreter Lock (GIL).  The _PyOS_ReadlineTState
+variable is set in Python's outer readline code prior to calling the
+user (GDB) supplied readline callback function, which for us is
+gdbpy_readline_wrapper.  The gdbpy_readline_wrapper function is called
+without the GIL held.
+
+Instead of using _PyOS_ReadlineTState, I propose that we switch to
+calling PyGILState_Ensure() and PyGILState_Release().  These functions
+will acquire the GIL based on the current thread.  I think this should
+be sufficient; I can't imagine why we'd be running
+gdbpy_readline_wrapper on one thread on behalf of a different Python
+thread.... that would be unexpected I think.
+
+Approved-By: Tom Tromey <tom@tromey.com>
+
+diff --git a/gdb/python/py-gdb-readline.c b/gdb/python/py-gdb-readline.c
+--- a/gdb/python/py-gdb-readline.c
++++ b/gdb/python/py-gdb-readline.c
+@@ -56,13 +56,11 @@ gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout,
+       if (except.reason == RETURN_QUIT)
+ 	return NULL;
+ 
+-      /* The thread state is nulled during gdbpy_readline_wrapper,
+-	 with the original value saved in the following undocumented
+-	 variable (see Python's Parser/myreadline.c and
+-	 Modules/readline.c).  */
+-      PyEval_RestoreThread (_PyOS_ReadlineTState);
++
++      /* This readline callback is called without the GIL held.  */
++      gdbpy_gil gil;
++
+       gdbpy_convert_exception (except);
+-      PyEval_SaveThread ();
+       return NULL;
+     }
+ 

diff --git a/gdb-rhbz2250652-gdbpy_gil.patch b/gdb-rhbz2250652-gdbpy_gil.patch
new file mode 100644
index 0000000..a72c350
--- /dev/null
+++ b/gdb-rhbz2250652-gdbpy_gil.patch
@@ -0,0 +1,81 @@
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= <ahajkova@redhat.com>
+Date: Mon, 8 Jan 2024 13:12:15 +0100
+Subject: gdb-rhbz2250652-gdbpy_gil.patch
+
+gdb: move gdbpy_gil into python-internal.h
+
+Move gdbpy_gil class into python-internal.h, the next
+commit wants to make use of this class from a file other
+than python.c.
+
+Approved-By: Tom Tromey <tom@tromey.com>
+
+diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
+--- a/gdb/python/python-internal.h
++++ b/gdb/python/python-internal.h
+@@ -754,6 +754,30 @@ class gdbpy_allow_threads
+   PyThreadState *m_save;
+ };
+ 
++/* A helper class to save and restore the GIL, but without touching
++   the other globals that are handled by gdbpy_enter.  */
++
++class gdbpy_gil
++{
++public:
++
++  gdbpy_gil ()
++    : m_state (PyGILState_Ensure ())
++  {
++  }
++
++  ~gdbpy_gil ()
++  {
++    PyGILState_Release (m_state);
++  }
++
++  DISABLE_COPY_AND_ASSIGN (gdbpy_gil);
++
++private:
++
++  PyGILState_STATE m_state;
++};
++
+ /* Use this after a TRY_EXCEPT to throw the appropriate Python
+    exception.  */
+ #define GDB_PY_HANDLE_EXCEPTION(Exception)	\
+diff --git a/gdb/python/python.c b/gdb/python/python.c
+--- a/gdb/python/python.c
++++ b/gdb/python/python.c
+@@ -257,30 +257,6 @@ gdbpy_enter::finalize ()
+   python_gdbarch = target_gdbarch ();
+ }
+ 
+-/* A helper class to save and restore the GIL, but without touching
+-   the other globals that are handled by gdbpy_enter.  */
+-
+-class gdbpy_gil
+-{
+-public:
+-
+-  gdbpy_gil ()
+-    : m_state (PyGILState_Ensure ())
+-  {
+-  }
+-
+-  ~gdbpy_gil ()
+-  {
+-    PyGILState_Release (m_state);
+-  }
+-
+-  DISABLE_COPY_AND_ASSIGN (gdbpy_gil);
+-
+-private:
+-
+-  PyGILState_STATE m_state;
+-};
+-
+ /* Set the quit flag.  */
+ 
+ static void

diff --git a/gdb.spec b/gdb.spec
index 45e3ab6..b89ade9 100644
--- a/gdb.spec
+++ b/gdb.spec
@@ -57,7 +57,7 @@ Version: 14.1
 
 # The release always contains a leading reserved number, start it at 1.
 # `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
-Release: 1%{?dist}
+Release: 2%{?dist}
 
 License: GPL-3.0-or-later AND BSD-3-clause AND FSFAP AND LGPL-2.1-or-later AND GPL-2.0-or-later AND LGPL-2.0-or-later AND LicenseRef-Fedora-Public-Domain AND GFDL-1.3-or-later AND LGPL-2.0-or-later WITH GCC-exception-2.0 AND GPL-3.0-or-later WITH GCC-exception-3.1 AND GPL-2.0-or-later WITH GNU-compiler-exception
 # Do not provide URL for snapshots as the file lasts there only for 2 days.
@@ -1250,6 +1250,10 @@ fi
 %endif
 
 %changelog
+* Mon Jan 8 2024 Alexandra Hájková <ahajkova@redhat.com> - 14.1-2
+- Backport upstream commits 7ae9ecfd801 and 8170efad364 to avoid
+  using _PyOS_ReadlineTState  (RHBZ 2250652).
+
 * Fri Dec 8 2023 Kevin Buettner <kevinb@redhat.com> - 14.1-1
 - Rebase to FSF GDB 14.1.
 - Update local patches:

                 reply	other threads:[~2026-06-28  0:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178260488707.1.12067086097576186225.rpms-gdb-9b9015292196@fedoraproject.org \
    --to=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox