08bfd0a
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
08bfd0a
From: Tom Tromey <tromey@adacore.com>
08bfd0a
Date: Wed, 15 Nov 2023 06:48:55 -0700
08bfd0a
Subject: gdb-handle-no-python-gdb-module.patch
08bfd0a
08bfd0a
;; Backport upstream commit 7d21600b31fe.
08bfd0a
08bfd0a
Check gdb_python_module in gdbpy_handle_missing_debuginfo
08bfd0a
08bfd0a
If you run gdb in the build tree without --data-directory, on a
08bfd0a
program that does not have debug info, it will crash, because
08bfd0a
gdbpy_handle_missing_debuginfo unconditionally uses gdb_python_module.
08bfd0a
08bfd0a
Other code in gdb using gdb_python_module checks it first and it
08bfd0a
seemes harmless to do the same thing here.  (gdb_python_initialized
08bfd0a
does not cover this case so that python can be partially initialized
08bfd0a
and still somewhat work.)
08bfd0a
08bfd0a
diff --git a/gdb/python/python.c b/gdb/python/python.c
08bfd0a
--- a/gdb/python/python.c
08bfd0a
+++ b/gdb/python/python.c
08bfd0a
@@ -1676,7 +1676,7 @@ gdbpy_handle_missing_debuginfo (const struct extension_language_defn *extlang,
08bfd0a
 				struct objfile *objfile)
08bfd0a
 {
08bfd0a
   /* Early exit if Python is not initialised.  */
08bfd0a
-  if (!gdb_python_initialized)
08bfd0a
+  if (!gdb_python_initialized || gdb_python_module == nullptr)
08bfd0a
     return {};
08bfd0a
 
08bfd0a
   struct gdbarch *gdbarch = objfile->arch ();