public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Array out of bounds
@ 2021-09-05  6:40 Jan-Benedict Glaw
  2021-09-05 18:06 ` Jan-Benedict Glaw
  0 siblings, 1 reply; 7+ messages in thread
From: Jan-Benedict Glaw @ 2021-09-05  6:40 UTC (permalink / raw)
  To: gdb

[-- Attachment #1: Type: text/plain, Size: 4673 bytes --]

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

-- 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Array out of bounds
  2021-09-05  6:40 Array out of bounds Jan-Benedict Glaw
@ 2021-09-05 18:06 ` Jan-Benedict Glaw
  2021-09-06  1:48   ` Simon Marchi
  0 siblings, 1 reply; 7+ messages in thread
From: Jan-Benedict Glaw @ 2021-09-05 18:06 UTC (permalink / raw)
  To: gdb

[-- Attachment #1: Type: text/plain, Size: 490 bytes --]

Hi!

On Sun, 2021-09-05 08:40:35 +0200, Jan-Benedict Glaw <jbglaw@lug-owl.de> wrote:
> 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:

Just to add: Seems to be independent of a target. Produces the same
warning/error for all tested targets using a current GCC.

Thanks,
  Jan-Benedict

-- 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Array out of bounds
  2021-09-05 18:06 ` Jan-Benedict Glaw
@ 2021-09-06  1:48   ` Simon Marchi
  2021-09-06  6:03     ` Jan-Benedict Glaw
  2021-09-06 10:24     ` Tom de Vries
  0 siblings, 2 replies; 7+ messages in thread
From: Simon Marchi @ 2021-09-06  1:48 UTC (permalink / raw)
  To: Jan-Benedict Glaw, gdb



On 2021-09-05 2:06 p.m., Jan-Benedict Glaw wrote:
> Hi!
> 
> On Sun, 2021-09-05 08:40:35 +0200, Jan-Benedict Glaw <jbglaw@lug-owl.de> wrote:
>> 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:
> 
> Just to add: Seems to be independent of a target. Produces the same
> warning/error for all tested targets using a current GCC.
> 
> Thanks,
>   Jan-Benedict
> 

I just built gcc at 66bba4dc263d ("Daily bump."), and I don't see it.

Simon

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Array out of bounds
  2021-09-06  1:48   ` Simon Marchi
@ 2021-09-06  6:03     ` Jan-Benedict Glaw
  2021-09-07 14:27       ` Simon Marchi
  2021-09-06 10:24     ` Tom de Vries
  1 sibling, 1 reply; 7+ messages in thread
From: Jan-Benedict Glaw @ 2021-09-06  6:03 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb

[-- Attachment #1: Type: text/plain, Size: 1471 bytes --]

Hi!

On Sun, 2021-09-05 21:48:22 -0400, Simon Marchi <simon.marchi@polymtl.ca> wrote:
> On 2021-09-05 2:06 p.m., Jan-Benedict Glaw wrote:
> > On Sun, 2021-09-05 08:40:35 +0200, Jan-Benedict Glaw <jbglaw@lug-owl.de> wrote:
> >> 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:
> > 
> > Just to add: Seems to be independent of a target. Produces the same
> > warning/error for all tested targets using a current GCC.
> 
> I just built gcc at 66bba4dc263d ("Daily bump."), and I don't see it.

For which target did you build? I actually don't see it for a small
number, ie:
  * xtensa-linux
  * fr30-elf
  * hppa2.0-hpux11.9
  * hppa64-hpux
  * hppa64-hpux11.0
  * hppa64-hpux11.3
  * ia64-elf
  * ia64-hpux
  * mmix-knuth-mmixware
  * powerpc-darwin7
  * pdp11-aout
  * powerpc-darwin8
  * s390x-ibm-tpf
  * x86_64-apple-darwin

Maybe you had a lucky pick? Only IPv6 connectivity at the moment, but
here are a few (failed) build logs for more common targets:

http://wolf.lug-owl.de:8080/jobs/gdb-alpha-netbsd/6
http://wolf.lug-owl.de:8080/jobs/gdb-m68k-linux/6
http://wolf.lug-owl.de:8080/jobs/gdb-mips-linux/6
http://wolf.lug-owl.de:8080/jobs/gdb-powerpc-linux/6
http://wolf.lug-owl.de:8080/jobs/gdb-x86_64-linux/6

MfG, JBG

-- 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Array out of bounds
  2021-09-06  1:48   ` Simon Marchi
  2021-09-06  6:03     ` Jan-Benedict Glaw
@ 2021-09-06 10:24     ` Tom de Vries
  2021-09-06 14:49       ` Tom de Vries
  1 sibling, 1 reply; 7+ messages in thread
From: Tom de Vries @ 2021-09-06 10:24 UTC (permalink / raw)
  To: Simon Marchi, Jan-Benedict Glaw, gdb

On 9/6/21 3:48 AM, Simon Marchi via Gdb wrote:
> 
> 
> On 2021-09-05 2:06 p.m., Jan-Benedict Glaw wrote:
>> Hi!
>>
>> On Sun, 2021-09-05 08:40:35 +0200, Jan-Benedict Glaw <jbglaw@lug-owl.de> wrote:
>>> 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:
>>
>> Just to add: Seems to be independent of a target. Produces the same
>> warning/error for all tested targets using a current GCC.
>>
>> Thanks,
>>   Jan-Benedict
>>
> 
> I just built gcc at 66bba4dc263d ("Daily bump."), and I don't see it.
> 

I've managed to reproduce, filed as PR gcc/102216 - "False positive
warray-bounds with -O2" @
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102216 .

Thanks,
- Tom

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Array out of bounds
  2021-09-06 10:24     ` Tom de Vries
@ 2021-09-06 14:49       ` Tom de Vries
  0 siblings, 0 replies; 7+ messages in thread
From: Tom de Vries @ 2021-09-06 14:49 UTC (permalink / raw)
  To: Simon Marchi, Jan-Benedict Glaw, gdb

On 9/6/21 12:24 PM, Tom de Vries via Gdb wrote:
> On 9/6/21 3:48 AM, Simon Marchi via Gdb wrote:
>>
>>
>> On 2021-09-05 2:06 p.m., Jan-Benedict Glaw wrote:
>>> Hi!
>>>
>>> On Sun, 2021-09-05 08:40:35 +0200, Jan-Benedict Glaw <jbglaw@lug-owl.de> wrote:
>>>> 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:
>>>
>>> Just to add: Seems to be independent of a target. Produces the same
>>> warning/error for all tested targets using a current GCC.
>>>
>>> Thanks,
>>>   Jan-Benedict
>>>
>>
>> I just built gcc at 66bba4dc263d ("Daily bump."), and I don't see it.
>>
> 
> I've managed to reproduce, filed as PR gcc/102216 - "False positive
> warray-bounds with -O2" @
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102216 .

FWIW, I've done a -Wno-array-bounds build at -O2 using the same gcc, and
that build succeeded.

Thanks,
- Tom

$ git diff
diff --git a/gdb/configure b/gdb/configure
index f0b1af4a6ea..410e69d09a1 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -16903,6 +16903,7 @@ build_warnings="-Wall -Wpointer-arith \
 -Wmissing-declarations \
 -Wmissing-prototypes \
 -Wstrict-null-sentinel \
+-Wno-array-bounds \
 "

 case "${host}" in
diff --git a/gdbserver/configure b/gdbserver/configure
index b227167e270..ca4b12adc76 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -9653,6 +9653,7 @@ build_warnings="-Wall -Wpointer-arith \
 -Wmissing-declarations \
 -Wmissing-prototypes \
 -Wstrict-null-sentinel \
+-Wno-array-bounds \
 "

 case "${host}" in
diff --git a/gdbsupport/configure b/gdbsupport/configure
index a9dd02c5b72..f39d1a794a2 100755
--- a/gdbsupport/configure
+++ b/gdbsupport/configure
@@ -10138,6 +10138,7 @@ build_warnings="-Wall -Wpointer-arith \
 -Wmissing-declarations \
 -Wmissing-prototypes \
 -Wstrict-null-sentinel \
+-Wno-array-bounds \
 "

 case "${host}" in
diff --git a/gdbsupport/warning.m4 b/gdbsupport/warning.m4
index 46036fa461e..f68e9cf3778 100644
--- a/gdbsupport/warning.m4
+++ b/gdbsupport/warning.m4
@@ -53,6 +53,7 @@ build_warnings="-Wall -Wpointer-arith \
 -Wmissing-declarations \
 -Wmissing-prototypes \
 -Wstrict-null-sentinel \
+-Wno-array-bounds \
 "

 case "${host}" in


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Array out of bounds
  2021-09-06  6:03     ` Jan-Benedict Glaw
@ 2021-09-07 14:27       ` Simon Marchi
  0 siblings, 0 replies; 7+ messages in thread
From: Simon Marchi @ 2021-09-07 14:27 UTC (permalink / raw)
  To: Jan-Benedict Glaw; +Cc: gdb



On 2021-09-06 2:03 a.m., Jan-Benedict Glaw wrote:
> Hi!
> 
> On Sun, 2021-09-05 21:48:22 -0400, Simon Marchi <simon.marchi@polymtl.ca> wrote:
>> On 2021-09-05 2:06 p.m., Jan-Benedict Glaw wrote:
>>> On Sun, 2021-09-05 08:40:35 +0200, Jan-Benedict Glaw <jbglaw@lug-owl.de> wrote:
>>>> 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:
>>>
>>> Just to add: Seems to be independent of a target. Produces the same
>>> warning/error for all tested targets using a current GCC.
>>
>> I just built gcc at 66bba4dc263d ("Daily bump."), and I don't see it.
> 
> For which target did you build? I actually don't see it for a small
> number, ie:
>   * xtensa-linux
>   * fr30-elf
>   * hppa2.0-hpux11.9
>   * hppa64-hpux
>   * hppa64-hpux11.0
>   * hppa64-hpux11.3
>   * ia64-elf
>   * ia64-hpux
>   * mmix-knuth-mmixware
>   * powerpc-darwin7
>   * pdp11-aout
>   * powerpc-darwin8
>   * s390x-ibm-tpf
>   * x86_64-apple-darwin
> 
> Maybe you had a lucky pick? Only IPv6 connectivity at the moment, but
> here are a few (failed) build logs for more common targets:
> 
> http://wolf.lug-owl.de:8080/jobs/gdb-alpha-netbsd/6
> http://wolf.lug-owl.de:8080/jobs/gdb-m68k-linux/6
> http://wolf.lug-owl.de:8080/jobs/gdb-mips-linux/6
> http://wolf.lug-owl.de:8080/jobs/gdb-powerpc-linux/6
> http://wolf.lug-owl.de:8080/jobs/gdb-x86_64-linux/6
> 
> MfG, JBG

Since the failure is in language.c, the target should not matter, as
language.c is compiled the same way whatever the target.  Anyway, seems
like Tom managed to reproduce it and filed a gcc bug, thanks Tom!

Simon

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-09-07 14:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-05  6:40 Array out of bounds Jan-Benedict Glaw
2021-09-05 18:06 ` Jan-Benedict Glaw
2021-09-06  1:48   ` Simon Marchi
2021-09-06  6:03     ` Jan-Benedict Glaw
2021-09-07 14:27       ` Simon Marchi
2021-09-06 10:24     ` Tom de Vries
2021-09-06 14:49       ` Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).