Bug 2192105

Summary: gdb-13.1-3 rebuild fails [-Werror=dangling-pointer=] by g++ 13.1.1
Product: [Fedora] Fedora Reporter: John Reiser <jreiser>
Component: gdbAssignee: Kevin Buettner <kevinb>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 38CC: ahajkova, fweimer, guinevere, jan, keiths, kevinb, mcermak, mkolar
Target Milestone: ---Keywords: Regression
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: gdb-13.1-4.fc38 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-05 01:28:57 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description John Reiser 2023-04-29 15:40:05 UTC
Re-building gdb-13.1-3.fc38.src.rpm  fails because a newer g++ compiler detects the assignment of the address of a local variable to something which is not a local variable, which is a "dangling pointer" error.

make[2]: Entering directory '/home/jreiser/rpmbuild/BUILD/gdb-13.1/build-x86_64-redhat-linux-gnu-minimal/gdb'
g++ -x c++    -I. -I../../gdb -I../../gdb/config -DLOCALEDIR="\"/usr/share/locale\"" -DHAVE_CONFIG_H -I../../gdb/../include/opcode    -I../bfd -I../../gdb/../bfd -I../../gdb/../include -I../libdecnumber -I../../gdb/../libdecnumber  -I../../gdb/../gnulib/import -I../gnulib/import -I../../gdb/.. -I.. -I../../gdb/../libbacktrace/ -I../libbacktrace/     -I../../gdb/.. -pthread  -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-variable -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-compare -Wno-error=maybe-uninitialized -Wno-mismatched-tags -Wsuggest-override -Wimplicit-fallthrough=3 -Wduplicated-cond -Wshadow=local -Wdeprecated-copy -Wdeprecated-copy-dtor -Wredundant-move -Wmissing-declarations -Wstrict-null-sentinel -Wformat -Wformat-nonliteral -Wno-unused -Wno-deprecated-declarations -Wno-unused-function -Wno-stringop-overflow -Werror -O2  -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer       -c -o language.o -MT language.o -MMD -MP -MF ./.deps/language.Tpo ../../gdb/language.c
In file included from ../../gdb/frame-info.h:23,
                 from ../../gdb/gdbtypes.h:59,
                 from ../../gdb/symtab.h:28,
                 from ../../gdb/language.c:33:
In member function 'void intrusive_list<T, AsNode>::push_empty(T&) [with T = frame_info_ptr; AsNode = intrusive_base_node<frame_info_ptr>]',
    inlined from 'void intrusive_list<T, AsNode>::push_back(reference) [with T = frame_info_ptr; AsNode = intrusive_base_node<frame_info_ptr>]' at ../../gdb/../gdbsupport/intrusive_list.h:332:24,
    inlined from 'frame_info_ptr::frame_info_ptr(const frame_info_ptr&)' at ../../gdb/frame-info.h:63:26,
    inlined from 'CORE_ADDR skip_language_trampoline(frame_info_ptr, CORE_ADDR)' at ../../gdb/language.c:535:49:
../../gdb/../gdbsupport/intrusive_list.h:415:12: error: storing the address of local variable '<anonymous>' in 'frame_info_ptr::frame_list.intrusive_list<frame_info_ptr>::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:535:49: note: '<anonymous>' declared here
  535 |       CORE_ADDR real_pc = lang->skip_trampoline (frame, pc);
      |                           ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
../../gdb/frame-info.h:169:41: note: 'frame_info_ptr::frame_list' declared here
  169 |   static intrusive_list<frame_info_ptr> frame_list;
      |                                         ^~~~~~~~~~
cc1plus: all warnings being treated as errors


Reproducible: Always

Steps to Reproduce:
1. Install source code gdb-13.1-3.fc38.src.rpm
2. Install build dependencies of gdb
3. rpmbuild -bc gdb.spec
Actual Results:  
g++ -x c++    -I. -I../../gdb -I../../gdb/config -DLOCALEDIR="\"/usr/share/locale\"" -DHAVE_CONFIG_H -I../../gdb/../include/opcode    -I../bfd -I../../gdb/../bfd -I../../gdb/../include -I../libdecnumber -I../../gdb/../libdecnumber  -I../../gdb/../gnulib/import -I../gnulib/import -I../../gdb/.. -I.. -I../../gdb/../libbacktrace/ -I../libbacktrace/     -I../../gdb/.. -pthread  -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-variable -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-compare -Wno-error=maybe-uninitialized -Wno-mismatched-tags -Wsuggest-override -Wimplicit-fallthrough=3 -Wduplicated-cond -Wshadow=local -Wdeprecated-copy -Wdeprecated-copy-dtor -Wredundant-move -Wmissing-declarations -Wstrict-null-sentinel -Wformat -Wformat-nonliteral -Wno-unused -Wno-deprecated-declarations -Wno-unused-function -Wno-stringop-overflow -Werror -O2  -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer       -c -o language.o -MT language.o -MMD -MP -MF ./.deps/language.Tpo ../../gdb/language.c
In file included from ../../gdb/frame-info.h:23,
                 from ../../gdb/gdbtypes.h:59,
                 from ../../gdb/symtab.h:28,
                 from ../../gdb/language.c:33:
In member function 'void intrusive_list<T, AsNode>::push_empty(T&) [with T = frame_info_ptr; AsNode = intrusive_base_node<frame_info_ptr>]',
    inlined from 'void intrusive_list<T, AsNode>::push_back(reference) [with T = frame_info_ptr; AsNode = intrusive_base_node<frame_info_ptr>]' at ../../gdb/../gdbsupport/intrusive_list.h:332:24,
    inlined from 'frame_info_ptr::frame_info_ptr(const frame_info_ptr&)' at ../../gdb/frame-info.h:63:26,
    inlined from 'CORE_ADDR skip_language_trampoline(frame_info_ptr, CORE_ADDR)' at ../../gdb/language.c:535:49:
../../gdb/../gdbsupport/intrusive_list.h:415:12: error: storing the address of local variable '<anonymous>' in 'frame_info_ptr::frame_list.intrusive_list<frame_info_ptr>::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:535:49: note: '<anonymous>' declared here
  535 |       CORE_ADDR real_pc = lang->skip_trampoline (frame, pc);
      |                           ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
../../gdb/frame-info.h:169:41: note: 'frame_info_ptr::frame_list' declared here
  169 |   static intrusive_list<frame_info_ptr> frame_list;
      |                                         ^~~~~~~~~~
cc1plus: all warnings being treated as errors


Expected Results:  
Successful compilation and re-build

$ g++ --version
g++ (GCC) 13.1.1 20230426 (Red Hat 13.1.1-1)
$ uname -a
Linux fedora 6.2.13-300.fc38.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Apr 27 01:33:30 UTC 2023 x86_64 GNU/Linux

Comment 1 Kevin Buettner 2023-05-02 23:15:12 UTC
I think that Mark Wielaard has a fix for this problem:

https://sourceware.org/pipermail/gdb-patches/2023-May/199291.html

I'll backport this patch when it lands (in upstream).

If a workaround is needed before it lands, I can temporarily disable -Werror=dangling-pointer .

Comment 2 Fedora Update System 2023-05-03 21:17:47 UTC
FEDORA-2023-f935959ce4 has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2023-f935959ce4

Comment 3 Fedora Update System 2023-05-04 05:32:06 UTC
FEDORA-2023-f935959ce4 has been pushed to the Fedora 38 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-f935959ce4`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-f935959ce4

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 4 Fedora Update System 2023-05-05 01:28:57 UTC
FEDORA-2023-f935959ce4 has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.