Array out of bounds

Jan-Benedict Glaw jbglaw@lug-owl.de
Sun Sep 5 06:40:35 GMT 2021


Hi!

As I started with automated building/testing the GNU Toolchain again,
I found this when building GDB (make all-gdb) with a fairly recent GCC
on a Linux system (PC) when GDB is configured for
--target=aarch64-linux:

[all 2021-09-05 06:26:42] /usr/lib/gcc-snapshot/bin/g++ -x c++    -I. -I. -I./config -DLOCALEDIR="\"/tmp/gdb-aarch64-linux/share/locale\"" -DHAVE_CONFIG_H -I./../include/opcode -I./../readline/readline/.. -I./../zlib -I../bfd -I./../bfd -I./../include -I../libdecnumber -I./../libdecnumber  -I./../gnulib/import -I../gnulib/import -I./.. -I..  -DTUI=1    -I./.. -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 -Werror -g -O2   -c -o jit.o -MT jit.o -MMD -MP -MF ./.deps/jit.Tpo jit.c
[all 2021-09-05 06:26:53] /usr/lib/gcc-snapshot/bin/g++ -x c++    -I. -I. -I./config -DLOCALEDIR="\"/tmp/gdb-aarch64-linux/share/locale\"" -DHAVE_CONFIG_H -I./../include/opcode -I./../readline/readline/.. -I./../zlib -I../bfd -I./../bfd -I./../include -I../libdecnumber -I./../libdecnumber  -I./../gnulib/import -I../gnulib/import -I./.. -I..  -DTUI=1    -I./.. -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 -Werror -g -O2   -c -o language.o -MT language.o -MMD -MP -MF ./.deps/language.Tpo language.c
[all 2021-09-05 06:27:00] In file included from /usr/lib/gcc-snapshot/include/c++/12/functional:64,
[all 2021-09-05 06:27:00]                  from ./../gdbsupport/ptid.h:35,
[all 2021-09-05 06:27:00]                  from ./../gdbsupport/common-defs.h:198,
[all 2021-09-05 06:27:00]                  from defs.h:28,
[all 2021-09-05 06:27:00]                  from language.c:31:
[all 2021-09-05 06:27:00] In function 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = const char**; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(const char*, const char*)>]',
[all 2021-09-05 06:27:00]     inlined from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = const char**; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(const char*, const char*)>]' at /usr/lib/gcc-snapshot/include/c++/12/bits/stl_algo.h:1960:31,
[all 2021-09-05 06:27:00]     inlined from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = const char**; _Compare = bool (*)(const char*, const char*)]' at /usr/lib/gcc-snapshot/include/c++/12/bits/stl_algo.h:4868:18,
[all 2021-09-05 06:27:00]     inlined from 'void add_set_language_command()' at language.c:517:13,
[all 2021-09-05 06:27:00]     inlined from 'void _initialize_language()' at language.c:1203:28:
[all 2021-09-05 06:27:00] /usr/lib/gcc-snapshot/include/c++/12/bits/stl_algo.h:1869:32: error: array subscript 19 is outside array bounds of 'void [136]' [-Werror=array-bounds]
[all 2021-09-05 06:27:00]  1869 |           std::__insertion_sort(__first, __first + int(_S_threshold), __comp);
[all 2021-09-05 06:27:00]       |           ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[all 2021-09-05 06:27:00] In function 'void add_set_language_command()',
[all 2021-09-05 06:27:00]     inlined from 'void _initialize_language()' at language.c:1203:28:
[all 2021-09-05 06:27:00] language.c:499:78: note: at offset 152 into object of size 136 allocated by 'operator new []'
[all 2021-09-05 06:27:00]   499 |   language_names = new const char *[ARRAY_SIZE (language_defn::languages) + 2];
[all 2021-09-05 06:27:00]       |                                                                              ^
[all 2021-09-05 06:27:00] cc1plus: all warnings being treated as errors
[all 2021-09-05 06:27:00] make[1]: *** [Makefile:1643: language.o] Error 1
[all 2021-09-05 06:27:00] make[1]: Leaving directory '/var/lib/laminar/run/gdb-aarch64-linux/8/binutils-gdb/gdb'

Thanks,
  Jan-Benedict

-- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/gdb/attachments/20210905/1aa42280/attachment.sig>


More information about the Gdb mailing list