public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/gdb] gdb-17.2-rebase-f44: Backport upstream commi 91874afabcd to fix RHEL2295897
@ 2026-06-28  0:01 Guinevere Larsen
  0 siblings, 0 replies; only message in thread
From: Guinevere Larsen @ 2026-06-28  0:01 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/gdb
Branch : gdb-17.2-rebase-f44
Commit : a45547080e359813c3aa02dcb12d760ad6bd9794
Author : Guinevere Larsen <blarsen@redhat.com>
Date   : 2024-07-05T10:59:59-03:00
Stats  : +160/-1 in 5 file(s)
URL    : https://src.fedoraproject.org/rpms/gdb/c/a45547080e359813c3aa02dcb12d760ad6bd9794?branch=gdb-17.2-rebase-f44

Log:
Backport upstream commi 91874afabcd to fix RHEL2295897

---
diff --git a/_gdb.spec.Patch.include b/_gdb.spec.Patch.include
index acf8486..3f17fa0 100644
--- a/_gdb.spec.Patch.include
+++ b/_gdb.spec.Patch.include
@@ -193,3 +193,7 @@ Patch047: gdb-add-rpm-suggestion-script.patch
 # Update x86 disassembler
 Patch048: gdb-rhbz2277160-apx-disasm.patch
 
+# backport of upstream commit 91874afabcd
+# This (somehow) solves a double-free when reading minimal symbols
+Patch049: gdb-rhel2295897-pre-read-DWZ-file-in-DWARF-reader.patch
+

diff --git a/_gdb.spec.patch.include b/_gdb.spec.patch.include
index ef55dd0..2ca0c1f 100644
--- a/_gdb.spec.patch.include
+++ b/_gdb.spec.patch.include
@@ -46,3 +46,4 @@
 %patch -p1 -P046
 %patch -p1 -P047
 %patch -p1 -P048
+%patch -p1 -P049

diff --git a/_patch_order b/_patch_order
index a3f47e7..387d80d 100644
--- a/_patch_order
+++ b/_patch_order
@@ -46,3 +46,4 @@ gdb-reformat-missing-debug-py-file.patch
 gdb-handle-no-python-gdb-module.patch
 gdb-add-rpm-suggestion-script.patch
 gdb-rhbz2277160-apx-disasm.patch
+gdb-rhel2295897-pre-read-DWZ-file-in-DWARF-reader.patch

diff --git a/gdb-rhel2295897-pre-read-DWZ-file-in-DWARF-reader.patch b/gdb-rhel2295897-pre-read-DWZ-file-in-DWARF-reader.patch
new file mode 100644
index 0000000..a212228
--- /dev/null
+++ b/gdb-rhel2295897-pre-read-DWZ-file-in-DWARF-reader.patch
@@ -0,0 +1,149 @@
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: Tom Tromey <tom@tromey.com>
+Date: Mon, 23 Oct 2023 16:44:53 -0600
+Subject: gdb-rhel2295897-pre-read-DWZ-file-in-DWARF-reader.patch
+
+;; backport of upstream commit 91874afabcd
+;; This (somehow) solves a double-free when reading minimal symbols
+
+Pre-read DWZ file in DWARF reader
+
+While working on background reading of DWARF, I came across the
+DWZ-reading code.  This code can query the user (via the debuginfod
+support) -- something that cannot be done off the main thread.
+
+Looking into it, I realized that this code can be run much earlier,
+avoiding this problem.  Digging a bit deeper, I also found a
+discrepancy here between how the DWARF reader works in "readnow" mode
+as compared to the normal modes.
+
+This patch cleans this up by trying to read the DWZ file earlier, and
+also by having the DWARF reader convert any exception here into a
+warning.  This unifies the various cases, but also makes it so that
+errors do not prevent gdb from continuing on to the extent possible.
+
+Regression tested on x86-64 Fedora 38.
+
+diff --git a/gdb/dwarf2/dwz.c b/gdb/dwarf2/dwz.c
+--- a/gdb/dwarf2/dwz.c
++++ b/gdb/dwarf2/dwz.c
+@@ -29,6 +29,7 @@
+ #include "gdbcore.h"
+ #include "gdbsupport/pathstuff.h"
+ #include "gdbsupport/scoped_fd.h"
++#include "run-on-main-thread.h"
+ 
+ const char *
+ dwz_file::read_string (struct objfile *objfile, LONGEST str_offset)
+@@ -196,8 +197,20 @@ dwarf2_get_dwz_file (dwarf2_per_bfd *per_bfd, bool require)
+   size_t buildid_len;
+   bfd_byte *buildid;
+ 
+-  if (per_bfd->dwz_file != NULL)
+-    return per_bfd->dwz_file.get ();
++  if (per_bfd->dwz_file.has_value ())
++    {
++      dwz_file *result = per_bfd->dwz_file->get ();
++      if (require && result == nullptr)
++	error (_("could not read '.gnu_debugaltlink' section"));
++      return result;
++    }
++
++  /* This may query the user via the debuginfod support, so it may
++     only be run in the main thread.  */
++  gdb_assert (is_main_thread ());
++
++  /* Set this early, so that on error it remains NULL.  */
++  per_bfd->dwz_file.emplace (nullptr);
+ 
+   bfd_set_error (bfd_error_no_error);
+   gdb::unique_xmalloc_ptr<char> data
+@@ -283,5 +296,5 @@ dwarf2_get_dwz_file (dwarf2_per_bfd *per_bfd, bool require)
+ 
+   gdb_bfd_record_inclusion (per_bfd->obfd, result->dwz_bfd.get ());
+   per_bfd->dwz_file = std::move (result);
+-  return per_bfd->dwz_file.get ();
++  return per_bfd->dwz_file->get ();
+ }
+diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
+--- a/gdb/dwarf2/read.c
++++ b/gdb/dwarf2/read.c
+@@ -3387,6 +3387,17 @@ dwarf2_initialize_objfile (struct objfile *objfile)
+ 
+   dwarf_read_debug_printf ("called");
+ 
++  /* Try to fetch any potential dwz file early, while still on the
++     main thread.  */
++  try
++    {
++      dwarf2_get_dwz_file (per_bfd);
++    }
++  catch (const gdb_exception_error &err)
++    {
++      warning (_("%s"), err.what ());
++    }
++
+   /* If we're about to read full symbols, don't bother with the
+      indices.  In this case we also don't care if some other debug
+      format is making psymtabs, because they are all about to be
+@@ -5294,16 +5305,7 @@ create_all_units (dwarf2_per_objfile *per_objfile)
+ 				  &per_objfile->per_bfd->abbrev, 0,
+ 				  types_htab, rcuh_kind::TYPE);
+ 
+-  dwz_file *dwz;
+-  try
+-    {
+-      dwz = dwarf2_get_dwz_file (per_objfile->per_bfd);
+-    }
+-  catch (const gdb_exception_error &)
+-    {
+-      per_objfile->per_bfd->all_units.clear ();
+-      throw;
+-    }
++  dwz_file *dwz = dwarf2_get_dwz_file (per_objfile->per_bfd);
+   if (dwz != NULL)
+     {
+       /* Pre-read the sections we'll need to construct an index.  */
+diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
+--- a/gdb/dwarf2/read.h
++++ b/gdb/dwarf2/read.h
+@@ -520,7 +520,7 @@ struct dwarf2_per_bfd
+ 
+   /* The shared '.dwz' file, if one exists.  This is used when the
+      original data was compressed using 'dwz -m'.  */
+-  std::unique_ptr<struct dwz_file> dwz_file;
++  gdb::optional<std::unique_ptr<struct dwz_file>> dwz_file;
+ 
+   /* Whether copy relocations are supported by this object format.  */
+   bool can_copy;
+diff --git a/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp b/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp
+--- a/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp
++++ b/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp
+@@ -142,13 +142,6 @@ proc do_test {} {
+ 
+     gdb_load ${::binfile}-${::testname}
+ 
+-    if { $::testname == "mismatch" && [readnow] } {
+-	# Main is found in the minimal symbols.  When using readnow, a
+-	# failure to read the dwarf also causes the minimal symbols to be
+-	# unavailable.
+-	# Setup a kfail for "FAIL: gdb_breakpoint: set breakpoint at main".
+-	setup_kfail "symtab/26797" *-*-*
+-    }
+     if {![runto_main]} {
+ 	return
+     }
+diff --git a/gdb/testsuite/gdb.dwarf2/no-gnu-debuglink.exp b/gdb/testsuite/gdb.dwarf2/no-gnu-debuglink.exp
+--- a/gdb/testsuite/gdb.dwarf2/no-gnu-debuglink.exp
++++ b/gdb/testsuite/gdb.dwarf2/no-gnu-debuglink.exp
+@@ -37,8 +37,8 @@ if { [build_executable $testfile.exp $testfile [list $srcfile $asm_file]] } {
+ 
+ clean_restart
+ 
+-set msg "\r\ncould not find '\.gnu_debugaltlink' file for \[^\r\n\]*"
++set msg "\r\nwarning: could not find '\.gnu_debugaltlink' file for \[^\r\n\]*"
+ gdb_test "file $binfile" "$msg" "file command"
+ 
+ set question "Load new symbol table from .*\? .y or n. "
+-gdb_test "file $binfile" "$msg" "file command, again" $question "y"
++gdb_test "file $binfile" "" "file command, again" $question "y"

diff --git a/gdb.spec b/gdb.spec
index d63eeae..8bda458 100644
--- a/gdb.spec
+++ b/gdb.spec
@@ -45,7 +45,7 @@ Version: 14.2
 
 # 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: 13%{?dist}
+Release: 14%{?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.
@@ -926,6 +926,10 @@ fi
 # endif scl
 
 %changelog
+* Fri Jul  5 2024 Guinevere Larsen <blarsen@redhat.com> - 14.2-14
+- backport commit 91874afabcd to solve RHEL-2295897
+  This fixes a double free when debugging mysql-workbench
+
 * Thu Jun 27 2024 Kevin Buettner <kevinb@redhat.com> - 14.2-13
 - Revise rpm-suggestions.py script so that message regarding
   a not-found 'rpm' module is deferred until just prior to

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-28  0:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-28  0:01 [rpms/gdb] gdb-17.2-rebase-f44: Backport upstream commi 91874afabcd to fix RHEL2295897 Guinevere Larsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox