diff --git a/_gdb.spec.Patch.include b/_gdb.spec.Patch.include index 7376b4e..46a73bf 100644 --- a/_gdb.spec.Patch.include +++ b/_gdb.spec.Patch.include @@ -220,3 +220,7 @@ Patch051: gdb-rhbz2183595-rustc-inside_main.patch # (Nick Clifton, binutils/29988) Patch052: gdb-binutils29988-read_indexed_address.patch +# Backport upstream patch fixing a "dangling pointer" build problem +# first seen when building with GCC 13.1.1 20230426 (Red Hat ;; 13.1.1-1). +Patch053: gdb-rhbz2192105-ftbs-dangling-pointer + diff --git a/_gdb.spec.patch.include b/_gdb.spec.patch.include index d954063..8ec13e9 100644 --- a/_gdb.spec.patch.include +++ b/_gdb.spec.patch.include @@ -50,3 +50,4 @@ %patch -p1 -P050 %patch -p1 -P051 %patch -p1 -P052 +%patch -p1 -P053 diff --git a/_patch_order b/_patch_order index 915ec2e..fb645b7 100644 --- a/_patch_order +++ b/_patch_order @@ -50,3 +50,4 @@ gdb-rhbz1553104-s390x-arch12-test.patch gdb-rhbz2177655-aarch64-pauth-valid-regcache.patch gdb-rhbz2183595-rustc-inside_main.patch gdb-binutils29988-read_indexed_address.patch +gdb-rhbz2192105-ftbs-dangling-pointer diff --git a/gdb-rhbz2192105-ftbs-dangling-pointer b/gdb-rhbz2192105-ftbs-dangling-pointer new file mode 100644 index 0000000..26ced86 --- /dev/null +++ b/gdb-rhbz2192105-ftbs-dangling-pointer @@ -0,0 +1,107 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Kevin Buettner +Date: Wed, 3 May 2023 11:28:24 -0700 +Subject: gdb-rhbz2192105-ftbs-dangling-pointer +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +;; Backport upstream patch fixing a "dangling pointer" build problem +;; first seen when building with GCC 13.1.1 20230426 (Red Hat ;; 13.1.1-1). + +Pass const frame_info_ptr reference for skip_[language_]trampoline + +g++ 13.1.1 produces a -Werror=dangling-pointer= + +In file included from ../../binutils-gdb/gdb/frame.h:75, + from ../../binutils-gdb/gdb/symtab.h:40, + from ../../binutils-gdb/gdb/language.c:33: +In member function ‘void intrusive_list::push_empty(T&) [with T = frame_info_ptr; AsNode = intrusive_base_node]’, + inlined from ‘void intrusive_list::push_back(reference) [with T = frame_info_ptr; AsNode = intrusive_base_node]’ at gdbsupport/intrusive_list.h:332:24, + inlined from ‘frame_info_ptr::frame_info_ptr(const frame_info_ptr&)’ at gdb/frame.h:241:26, + inlined from ‘CORE_ADDR skip_language_trampoline(frame_info_ptr, CORE_ADDR)’ at gdb/language.c:530:49: +gdbsupport/intrusive_list.h:415:12: error: storing the address of local variable ‘’ in ‘frame_info_ptr::frame_list.intrusive_list::m_back’ [-Werror=dangling-pointer=] + 415 | m_back = &elem; + | ~~~~~~~^~~~~~~ +gdb/language.c: In function ‘CORE_ADDR skip_language_trampoline(frame_info_ptr, CORE_ADDR)’: +gdb/language.c:530:49: note: ‘’ declared here + 530 | CORE_ADDR real_pc = lang->skip_trampoline (frame, pc); + | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ +gdb/frame.h:359:41: note: ‘frame_info_ptr::frame_list’ declared here + 359 | static intrusive_list frame_list; + | ^~~~~~~~~~ + +Each new frame_info_ptr is being pushed on a static frame list and g++ +cannot see why that is safe in case the frame_info_ptr is created and +destroyed immediately when passed as value. + +It isn't clear why only in this one place g++ sees the issue (probably +because it can inline enough code in this specific case). + +Since passing the frame_info_ptr as const reference is cheaper, use +that as workaround for this warning. + +PR build/30413 +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30413 + +Tested-by: Kevin Buettner +Reviewed-by: Kevin Buettner +Reviewed-by: Tom Tromey + +diff --git a/gdb/c-lang.c b/gdb/c-lang.c +--- a/gdb/c-lang.c ++++ b/gdb/c-lang.c +@@ -1003,7 +1003,7 @@ class cplus_language : public language_defn + + /* See language.h. */ + +- CORE_ADDR skip_trampoline (frame_info_ptr fi, ++ CORE_ADDR skip_trampoline (const frame_info_ptr &fi, + CORE_ADDR pc) const override + { + return cplus_skip_trampoline (fi, pc); +diff --git a/gdb/language.c b/gdb/language.c +--- a/gdb/language.c ++++ b/gdb/language.c +@@ -528,7 +528,7 @@ add_set_language_command () + Return the result from the first that returns non-zero, or 0 if all + `fail'. */ + CORE_ADDR +-skip_language_trampoline (frame_info_ptr frame, CORE_ADDR pc) ++skip_language_trampoline (const frame_info_ptr &frame, CORE_ADDR pc) + { + for (const auto &lang : language_defn::languages) + { +diff --git a/gdb/language.h b/gdb/language.h +--- a/gdb/language.h ++++ b/gdb/language.h +@@ -471,7 +471,7 @@ struct language_defn + If that PC falls in a trampoline belonging to this language, return + the address of the first pc in the real function, or 0 if it isn't a + language tramp for this language. */ +- virtual CORE_ADDR skip_trampoline (frame_info_ptr fi, CORE_ADDR pc) const ++ virtual CORE_ADDR skip_trampoline (const frame_info_ptr &fi, CORE_ADDR pc) const + { + return (CORE_ADDR) 0; + } +@@ -789,7 +789,7 @@ extern const char *language_str (enum language); + + /* Check for a language-specific trampoline. */ + +-extern CORE_ADDR skip_language_trampoline (frame_info_ptr, CORE_ADDR pc); ++extern CORE_ADDR skip_language_trampoline (const frame_info_ptr &, CORE_ADDR pc); + + /* Return demangled language symbol, or NULL. */ + extern gdb::unique_xmalloc_ptr language_demangle +diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c +--- a/gdb/objc-lang.c ++++ b/gdb/objc-lang.c +@@ -282,7 +282,7 @@ class objc_language : public language_defn + + /* See language.h. */ + +- CORE_ADDR skip_trampoline (frame_info_ptr frame, ++ CORE_ADDR skip_trampoline (const frame_info_ptr &frame, + CORE_ADDR stop_pc) const override + { + struct gdbarch *gdbarch = get_frame_arch (frame); diff --git a/gdb.spec b/gdb.spec index 75edff2..458e3e4 100644 --- a/gdb.spec +++ b/gdb.spec @@ -57,7 +57,7 @@ Version: 13.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: 4%{?dist} +Release: 5%{?dist} License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and LGPLv3+ and BSD and Public Domain and GFDL # Do not provide URL for snapshots as the file lasts there only for 2 days. @@ -1249,6 +1249,10 @@ fi %endif %changelog +* Wed May 3 2023 Kevin Buettner 13.1-5 +- Backport "Pass const frame_info_ptr reference for + skip_[language_]trampoline". (Mark Wielaard, RHBZ 2192105, build/30413) + * Tue May 2 2023 Andrew Burgess - Remove gdb-opcodes-clflushopt-test.patch. This patch tests that GDB can disassemble the clflushopt instruction correctly. Such