Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* sparc-tdep.c: __builtin___memcpy_chk overflows destination buffer
@ 2009-09-17  2:36 Ralf Corsepius
  2009-09-17  6:25 ` Mark Kettenis
  2009-09-17 18:05 ` Jan Kratochvil
  0 siblings, 2 replies; 5+ messages in thread
From: Ralf Corsepius @ 2009-09-17  2:36 UTC (permalink / raw)
  To: gdb-patches; +Cc: Joel Sherrill

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

Hi,

building gdb-6.8.91 for sparc-rtems* (sparc-elf) on F11/x86_64
raises this warning:

gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions 
-fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic   -I. 
-I../../gdb-6.8.91/gdb -I../../gdb-6.8.91/gdb/common 
-I../../gdb-6.8.91/gdb/config 
-DLOCALEDIR="\"/opt/rtems-4.10/share/locale\"" -DHAVE_CONFIG_H 
-I../../gdb-6.8.91/gdb/../include/opcode  -I../bfd 
-I../../gdb-6.8.91/gdb/../bfd -I../../gdb-6.8.91/gdb/../include 
-I../libdecnumber -I../../gdb-6.8.91/gdb/../libdecnumber 
-I../../gdb-6.8.91/gdb/gnulib -Ignulib  -DMI_OUT=1 -DTUI=1   -Wall 
-Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral 
-Wno-pointer-sign -Wno-unused -Wno-switch -Wno-char-subscripts  -c -o 
sparc-tdep.o -MT sparc-tdep.o -MMD -MP -MF .deps/sparc-tdep.Tpo 
../../gdb-6.8.91/gdb/sparc-tdep.c
In file included from /usr/include/string.h:641,
                  from gnulib/string.h:24,
                  from ../../gdb-6.8.91/gdb/gdb_string.h:26,
                  from ../../gdb-6.8.91/gdb/vec.h:26,
                  from ../../gdb-6.8.91/gdb/breakpoint.h:26,
                  from ../../gdb-6.8.91/gdb/inferior.h:37,
                  from ../../gdb-6.8.91/gdb/sparc-tdep.c:32:
In function 'memcpy',
     inlined from 'sparc32_store_return_value' at 
../../gdb-6.8.91/gdb/sparc-tdep.c:1112,
     inlined from 'sparc32_return_value' at 
../../gdb-6.8.91/gdb/sparc-tdep.c:1170:
/usr/include/bits/string3.h:52: warning: call to __builtin___memcpy_chk 
will always overflow destination buffer

The patch below is what I am including into the rtems-gdb patches.

I don't have write access to gdb-cvs, and would appreciate it, if 
somebody else would apply the patch for me.

TIA,

	Ralf

[-- Attachment #2: sparc-gdb-6.8.91-gdb-sim.diff --]
[-- Type: text/plain, Size: 641 bytes --]

2009-09-17	Ralf Corsépius <ralf.corsepius@rtems.org>

	* sparc-tdep.c (sparc32_store_return_value): Use size_t as 
	return type of TYPE_LENGTH(type).


diff -Naur gdb-6.8.91.orig/gdb/sparc-tdep.c gdb-6.8.91/gdb/sparc-tdep.c
--- gdb-6.8.91.orig/gdb/sparc-tdep.c	2009-09-07 19:52:41.000000000 +0200
+++ gdb-6.8.91/gdb/sparc-tdep.c	2009-09-17 03:43:48.000000000 +0200
@@ -1100,7 +1100,7 @@
 sparc32_store_return_value (struct type *type, struct regcache *regcache,
 			    const gdb_byte *valbuf)
 {
-  int len = TYPE_LENGTH (type);
+  size_t len = TYPE_LENGTH (type);
   gdb_byte buf[8];
 
   gdb_assert (!sparc_structure_or_union_p (type));

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

* Re: sparc-tdep.c: __builtin___memcpy_chk overflows destination buffer
  2009-09-17  2:36 sparc-tdep.c: __builtin___memcpy_chk overflows destination buffer Ralf Corsepius
@ 2009-09-17  6:25 ` Mark Kettenis
  2009-09-17 15:43   ` Joel Brobecker
  2009-09-17 18:05 ` Jan Kratochvil
  1 sibling, 1 reply; 5+ messages in thread
From: Mark Kettenis @ 2009-09-17  6:25 UTC (permalink / raw)
  To: ralf.corsepius; +Cc: gdb-patches, Joel.Sherrill

> Date: Thu, 17 Sep 2009 04:36:00 +0200
> From: Ralf Corsepius <ralf.corsepius@rtems.org>

You sent the diff as bas64 encoded MIME attachment which makes it
difficult for me to review your diff.  Can you send it inline or as a
normal 7-bit ASCII encoded attachments?

Thanks,

Mark


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

* Re: sparc-tdep.c: __builtin___memcpy_chk overflows destination  buffer
  2009-09-17  6:25 ` Mark Kettenis
@ 2009-09-17 15:43   ` Joel Brobecker
  0 siblings, 0 replies; 5+ messages in thread
From: Joel Brobecker @ 2009-09-17 15:43 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: ralf.corsepius, gdb-patches, Joel.Sherrill

> You sent the diff as bas64 encoded MIME attachment which makes it
> difficult for me to review your diff.  Can you send it inline or as a
> normal 7-bit ASCII encoded attachments?

Here is the patch. I don't really understand what the problem is,
however, and I'm quite hesitant about this patch. I wasn't able to
reproduce the build failure, so couldn't investigate any further.


2009-09-17	Ralf Corsépius <ralf.corsepius@rtems.org>

	* sparc-tdep.c (sparc32_store_return_value): Use size_t as 
	return type of TYPE_LENGTH(type).


diff -Naur gdb-6.8.91.orig/gdb/sparc-tdep.c gdb-6.8.91/gdb/sparc-tdep.c
--- gdb-6.8.91.orig/gdb/sparc-tdep.c	2009-09-07 19:52:41.000000000 +0200
+++ gdb-6.8.91/gdb/sparc-tdep.c	2009-09-17 03:43:48.000000000 +0200
@@ -1100,7 +1100,7 @@
 sparc32_store_return_value (struct type *type, struct regcache *regcache,
 			    const gdb_byte *valbuf)
 {
-  int len = TYPE_LENGTH (type);
+  size_t len = TYPE_LENGTH (type);
   gdb_byte buf[8];
 
   gdb_assert (!sparc_structure_or_union_p (type));

-- 
Joel


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

* Re: sparc-tdep.c: __builtin___memcpy_chk overflows destination  buffer
  2009-09-17  2:36 sparc-tdep.c: __builtin___memcpy_chk overflows destination buffer Ralf Corsepius
  2009-09-17  6:25 ` Mark Kettenis
@ 2009-09-17 18:05 ` Jan Kratochvil
  2009-09-18  5:01   ` Ralf Corsepius
  1 sibling, 1 reply; 5+ messages in thread
From: Jan Kratochvil @ 2009-09-17 18:05 UTC (permalink / raw)
  To: Ralf Corsepius; +Cc: gdb-patches, Joel Sherrill

Hi Ralf,

I think this is more a GCC fault:
	[4.3/4.4/4.5 regression] Bogus __builtin___memcpy_chk overflow warning
	http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37060


Regards,
Jan


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

* Re: sparc-tdep.c: __builtin___memcpy_chk overflows destination  buffer
  2009-09-17 18:05 ` Jan Kratochvil
@ 2009-09-18  5:01   ` Ralf Corsepius
  0 siblings, 0 replies; 5+ messages in thread
From: Ralf Corsepius @ 2009-09-18  5:01 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Ralf Corsepius, gdb-patches, Joel Sherrill

On 09/17/2009 08:04 PM, Jan Kratochvil wrote:
> Hi Ralf,
>
> I think this is more a GCC fault:
> 	[4.3/4.4/4.5 regression] Bogus __builtin___memcpy_chk overflow warning
> 	http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37060
I am inclined to agree, because this matches with what I observe:

This warning shows on
fedora-10-x86_64 (gcc-4.3.2),
fedora-11-x86_64 (gcc-4.4.1),
fedora-12-x86_64/rawhide (gcc-4.4.1),
openSUSE-11.0-x86_64 (gcc-4.3),
openSUSE-11.1-x86_64 (gcc-4.3).

I does not show on
openSUSE-10.3-x86_64 (gcc-4.2), centos-5-x86_64 (gcc-4.1.2) and the 
i[356]86 variants of these OSes.


Anyway, using "size_t" instead of "int" suppresses the warning on all of 
them :-)

Ralf




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

end of thread, other threads:[~2009-09-18  5:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-17  2:36 sparc-tdep.c: __builtin___memcpy_chk overflows destination buffer Ralf Corsepius
2009-09-17  6:25 ` Mark Kettenis
2009-09-17 15:43   ` Joel Brobecker
2009-09-17 18:05 ` Jan Kratochvil
2009-09-18  5:01   ` Ralf Corsepius

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox