Re: [PATCH v2 0/8] Remove stabs support from GDB

Luis
2025-10-23T00:59:15Z

On 22/10/2025 20:19, Luis wrote:
> Hi,
>
> On Wed, Oct 22, 2025, 14:19 Guinevere Larsen <guinevere@redhat.com
> <mailto:guinevere@redhat.com>> wrote:
>
> On 10/22/25 10:08 AM, Tom Tromey wrote:
> >>>>>> "Luis" == Luis  <luis.machado.foss@gmail.com
> <mailto:luis.machado.foss@gmail.com>> writes:
> > Luis> Looks like gcc (13.3.0 at least) is a bit grumpy with this
> and there
> > Luis> are a few -Werror=array-bounds= warnings stopping the build,
> > Luis> apparently from changes to gdb/xcoffread.c.
> >
> > Could you post them here?
> >
> > IIRC some versions of GCC issued these kinds of errors incorrectly.
> > So it's possible the fix might be just to disable the warning for
> that build.
> >
> > Tom
> >
> I believe that is the case, since I just installed gcc-13.3.1-2 from
> fedora 40 and upstream built fine, so I think either the .1 shame
> release  (see pride versioning: https://pridever.org/ <https://
> pridever.org/> :p), or some
> fedora patch, fixed a gcc bug related to that.
>
>
> Yeah, sorry for the poor report. It happened on a different machine
> unreachable from the one I sent the message.
>
> I'll reproduce it and paste the exact messages. I tried to make sense of
> it a bit, but seemed a bit odd.
>
>
> --
> Cheers,
> Guinevere Larsen
> It/she
>

Ok, I played with this a bit more and reproduced it again on my end. The
problem seems to be related to enabling ubsan in configure for the build.

So if I configure with the following...

./configure --enable-targets=all --with-python=python3 --without-guile
--enable-ubsan

I get these errors...

---

In file included from /usr/include/c++/13/vector:66,
from /usr/include/c++/13/functional:64,
from
../../../repos/binutils-gdb/gdb/../gdbsupport/ptid.h:35,
from
../../../repos/binutils-gdb/gdb/../gdbsupport/common-defs.h:212,
from ./../../../repos/binutils-gdb/gdb/defs.h:26,
from <command-line>:
In member function ‘std::vector<_Tp, _Alloc>::reference std::vector<_Tp,
_Alloc>::operator[](size_type) [with _Tp = void*; _Alloc =
std::allocator<void*>]’,
inlined from ‘void* registry<T>::get(unsigned int) [with T =
objfile]’ at ../../../repos/binutils-gdb/gdb/registry.h:213:24,
inlined from ‘DATA* registry<T>::key<DATA, Deleter>::get(T*) const
[with DATA = xcoff_symfile_info; Deleter =
std::default_delete<xcoff_symfile_info>; T = objfile]’ at
../../../repos/binutils-gdb/gdb/registry.h:111:36,
inlined from ‘void enter_line_range(subfile*, unsigned int,
unsigned int, CORE_ADDR, CORE_ADDR, unsigned int*)’ at
../../../repos/binutils-gdb/gdb/xcoffread.c:544:18:
/usr/include/c++/13/bits/stl_vector.h:1129:32: error: array subscript 0
is outside array bounds of ‘registry<objfile> [0]’ [-Werror=array-bounds=]
1129 | return *(this->_M_impl._M_start + __n);
| ~~~~~~~~~~~~~~^~~~~~~~
In function ‘void enter_line_range(subfile*, unsigned int, unsigned int,
CORE_ADDR, CORE_ADDR, unsigned int*)’:
cc1plus: note: source object is likely at address zero
In member function ‘std::vector<_Tp, _Alloc>::reference std::vector<_Tp,
_Alloc>::operator[](size_type) [with _Tp = void*; _Alloc =
std::allocator<void*>]’,
inlined from ‘void* registry<T>::get(unsigned int) [with T =
objfile]’ at ../../../repos/binutils-gdb/gdb/registry.h:213:24,
inlined from ‘DATA* registry<T>::key<DATA, Deleter>::get(T*) const
[with DATA = xcoff_symfile_info; Deleter =
std::default_delete<xcoff_symfile_info>; T = objfile]’ at
../../../repos/binutils-gdb/gdb/registry.h:111:36,
inlined from ‘void enter_line_range(subfile*, unsigned int,
unsigned int, CORE_ADDR, CORE_ADDR, unsigned int*)’ at
../../../repos/binutils-gdb/gdb/xcoffread.c:544:18:
/usr/include/c++/13/bits/stl_vector.h:1129:32: error: array subscript 0
is outside array bounds of ‘registry<objfile> [0]’ [-Werror=array-bounds=]
In function ‘void enter_line_range(subfile*, unsigned int, unsigned int,
CORE_ADDR, CORE_ADDR, unsigned int*)’:
cc1plus: note: source object is likely at address zero
In member function ‘std::vector<_Tp, _Alloc>::reference std::vector<_Tp,
_Alloc>::operator[](size_type) [with _Tp = void*; _Alloc =
std::allocator<void*>]’,
inlined from ‘void* registry<T>::get(unsigned int) [with T =
objfile]’ at ../../../repos/binutils-gdb/gdb/registry.h:213:24,
inlined from ‘DATA* registry<T>::key<DATA, Deleter>::get(T*) const
[with DATA = xcoff_symfile_info; Deleter =
std::default_delete<xcoff_symfile_info>; T = objfile]’ at
../../../repos/binutils-gdb/gdb/registry.h:111:36,
inlined from ‘void read_symbol(internal_syment*, int)’ at
../../../repos/binutils-gdb/gdb/xcoffread.c:612:38,
inlined from ‘CORE_ADDR read_symbol_nvalue(int)’ at
../../../repos/binutils-gdb/gdb/xcoffread.c:635:15,
inlined from ‘void enter_line_range(subfile*, unsigned int,
unsigned int, CORE_ADDR, CORE_ADDR, unsigned int*)’ at
../../../repos/binutils-gdb/gdb/xcoffread.c:572:29:
/usr/include/c++/13/bits/stl_vector.h:1129:32: error: array subscript 0
is outside array bounds of ‘registry<objfile> [0]’ [-Werror=array-bounds=]
1129 | return *(this->_M_impl._M_start + __n);
| ~~~~~~~~~~~~~~^~~~~~~~
In function ‘void enter_line_range(subfile*, unsigned int, unsigned int,
CORE_ADDR, CORE_ADDR, unsigned int*)’:
cc1plus: note: source object is likely at address zero
In member function ‘std::vector<_Tp, _Alloc>::reference std::vector<_Tp,
_Alloc>::operator[](size_type) [with _Tp = void*; _Alloc =
std::allocator<void*>]’,
inlined from ‘void* registry<T>::get(unsigned int) [with T =
objfile]’ at ../../../repos/binutils-gdb/gdb/registry.h:213:24,
inlined from ‘DATA* registry<T>::key<DATA, Deleter>::get(T*) const
[with DATA = xcoff_symfile_info; Deleter =
std::default_delete<xcoff_symfile_info>; T = objfile]’ at
../../../repos/binutils-gdb/gdb/registry.h:111:36,
inlined from ‘int read_symbol_lineno(int)’ at
../../../repos/binutils-gdb/gdb/xcoffread.c:649:37,
inlined from ‘void enter_line_range(subfile*, unsigned int,
unsigned int, CORE_ADDR, CORE_ADDR, unsigned int*)’ at
../../../repos/binutils-gdb/gdb/xcoffread.c:582:36:
/usr/include/c++/13/bits/stl_vector.h:1129:32: error: array subscript 0
is outside array bounds of ‘registry<objfile> [0]’ [-Werror=array-bounds=]
1129 | return *(this->_M_impl._M_start + __n);
| ~~~~~~~~~~~~~~^~~~~~~~
In function ‘void enter_line_range(subfile*, unsigned int, unsigned int,
CORE_ADDR, CORE_ADDR, unsigned int*)’:
cc1plus: note: source object is likely at address zero

---

If I drop the --enable-ubsan from configure, then the build completes
just fine.

Maybe not a show stopper, but would be nice to have working builds with
ubsan.

For reference, the system is using Mint 22.2, which might be equivalent
to Ubuntu 24.04.