Debian Bug report logs -
#619963
gcc-4.6: wrongly optimizes memmove() into memcpy()
Reported by: Remi Denis-Courmont <remi@remlab.net>
Date: Mon, 28 Mar 2011 17:21:05 UTC
Severity: important
Tags: pending
Merged with 624696,
624743
Found in version eglibc/2.11.2-10
Fixed in version eglibc/2.13-1
Done: Aurelien Jarno <aurelien@aurel32.net>
Bug is archived. No further changes may be made.
Toggle useless messages
Report forwarded
to debian-bugs-dist@lists.debian.org, Debian GCC Maintainers <debian-gcc@lists.debian.org>:
Bug#619963; Package gcc-4.6.
(Mon, 28 Mar 2011 17:21:08 GMT) (full text, mbox, link).
Acknowledgement sent
to Remi Denis-Courmont <remi@remlab.net>:
New Bug report received and forwarded. Copy sent to Debian GCC Maintainers <debian-gcc@lists.debian.org>.
(Mon, 28 Mar 2011 17:21:08 GMT) (full text, mbox, link).
Message #5 received at submit@bugs.debian.org (full text, mbox, reply):
Package: gcc-4.6
Version: 4.6.0-1
Severity: grave
Justification: renders package unusable
Hello,
Trying to compile VLC media player using Debian gcc-4.6.
It turns out that the compiler is silently replacing memmove() calls
with memcpy() ones, when it is clearly NOT a legal optimization. The
issue was uncovered with valgrind. For instance, this one is failing,
even though both source and destination obviously overlap:
memmove( &p_aout->pp_inputs[i_input], &p_aout->pp_inputs[i_input + 1],
(AOUT_MAX_INPUTS - i_input - 1) * sizeof(aout_input_t *) );
This results in memory corruption at run-time and eventually crashes.
Compiler flags used were: -g -O2 -ffast-math -funroll-loops -fPIC
I can provide the full .i file if needed.
Best regards,
-- System Information:
Debian Release: wheezy/sid
APT prefers unstable
APT policy: (100, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.38-1-686 (SMP w/2 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages gcc-4.6 depends on:
ii binutils 2.21.0.20110327-1 The GNU assembler, linker and bina
ii cpp-4.6 4.6.0-1 The GNU C preprocessor
ii gcc-4.6-base 4.6.0-1 The GNU Compiler Collection (base
ii libc6 2.11.2-11 Embedded GNU C Library: Shared lib
ii libcloog-ppl0 0.15.9-3 the Chunky Loop Generator (runtime
ii libgcc1 1:4.6.0-1 GCC support library
ii libgmp10 2:5.0.1+dfsg-7 Multiprecision arithmetic library
ii libgmpxx4ldbl 2:5.0.1+dfsg-7 Multiprecision arithmetic library
ii libgomp1 4.6.0-1 GCC OpenMP (GOMP) support library
ii libmpc2 0.9-2 multiple precision complex floatin
ii libmpfr4 3.0.0-9 multiple precision floating-point
ii libppl-c4 0.11.2-3 Parma Polyhedra Library (C interfa
ii libppl9 0.11.2-3 Parma Polyhedra Library (runtime l
ii libquadmath0 4.6.0-1 GCC Quad-Precision Math Library
ii zlib1g 1:1.2.3.4.dfsg-3 compression library - runtime
Versions of packages gcc-4.6 recommends:
ii libc6-dev 2.11.2-11 Embedded GNU C Library: Developmen
Versions of packages gcc-4.6 suggests:
pn binutils-gold <none> (no description available)
pn gcc-4.6-doc <none> (no description available)
pn gcc-4.6-locales <none> (no description available)
pn gcc-4.6-multilib <none> (no description available)
ii libgcc1-dbg 1:4.6.0-1 GCC support library (debug symbols
pn libgomp1-dbg <none> (no description available)
pn libmudflap0-4.6-dev <none> (no description available)
pn libmudflap0-dbg <none> (no description available)
pn libquadmath0-dbg <none> (no description available)
-- no debconf information
Information forwarded
to debian-bugs-dist@lists.debian.org, Debian GCC Maintainers <debian-gcc@lists.debian.org>:
Bug#619963; Package gcc-4.6.
(Mon, 28 Mar 2011 18:39:03 GMT) (full text, mbox, link).
Acknowledgement sent
to "Rémi Denis-Courmont" <remi@remlab.net>:
Extra info received and forwarded to list. Copy sent to Debian GCC Maintainers <debian-gcc@lists.debian.org>.
(Mon, 28 Mar 2011 18:39:03 GMT) (full text, mbox, link).
Message #10 received at 619963@bugs.debian.org (full text, mbox, reply):
Le lundi 28 mars 2011 21:06:31 Matthias Klose, vous avez écrit :
> severity 619963 important
> thanks
>
> On 28.03.2011 19:10, Remi Denis-Courmont wrote:
> > Package: gcc-4.6
> > Version: 4.6.0-1
> > Severity: grave
> > Justification: renders package unusable
>
> does it?
It does not compile Debian's "own" source code base correctly on i386.
What more do you need?
> > Trying to compile VLC media player using Debian gcc-4.6.
> > It turns out that the compiler is silently replacing memmove() calls
> > with memcpy() ones, when it is clearly NOT a legal optimization. The
> > issue was uncovered with valgrind. For instance, this one is failing,
> >
> > even though both source and destination obviously overlap:
> > memmove( &p_aout->pp_inputs[i_input], &p_aout->pp_inputs[i_input +
> > 1],
> >
> > (AOUT_MAX_INPUTS - i_input - 1) * sizeof(aout_input_t *) );
> >
> > This results in memory corruption at run-time and eventually crashes.
> >
> > Compiler flags used were: -g -O2 -ffast-math -funroll-loops -fPIC
> > I can provide the full .i file if needed.
>
> please could you provide a test case?
I don't have that at hand, unless you count the entire VLC a test case.
--
Rémi Denis-Courmont
Looking for a job: http://www.remlab.info/
http://fi.linkedin.com/in/remidenis
Information forwarded
to debian-bugs-dist@lists.debian.org, Debian GCC Maintainers <debian-gcc@lists.debian.org>:
Bug#619963; Package gcc-4.6.
(Mon, 28 Mar 2011 18:45:06 GMT) (full text, mbox, link).
Acknowledgement sent
to Matthias Klose <doko@debian.org>:
Extra info received and forwarded to list. Copy sent to Debian GCC Maintainers <debian-gcc@lists.debian.org>.
(Mon, 28 Mar 2011 18:45:06 GMT) (full text, mbox, link).
Message #15 received at 619963@bugs.debian.org (full text, mbox, reply):
severity 619963 important
thanks
On 28.03.2011 19:10, Remi Denis-Courmont wrote:
> Package: gcc-4.6
> Version: 4.6.0-1
> Severity: grave
> Justification: renders package unusable
does it?
> Trying to compile VLC media player using Debian gcc-4.6.
> It turns out that the compiler is silently replacing memmove() calls
> with memcpy() ones, when it is clearly NOT a legal optimization. The
> issue was uncovered with valgrind. For instance, this one is failing,
> even though both source and destination obviously overlap:
>
> memmove( &p_aout->pp_inputs[i_input], &p_aout->pp_inputs[i_input + 1],
> (AOUT_MAX_INPUTS - i_input - 1) * sizeof(aout_input_t *) );
>
> This results in memory corruption at run-time and eventually crashes.
>
> Compiler flags used were: -g -O2 -ffast-math -funroll-loops -fPIC
> I can provide the full .i file if needed.
please could you provide a test case?
thanks, Matthias
Severity set to 'important' from 'grave'
Request was from Matthias Klose <doko@debian.org>
to control@bugs.debian.org.
(Thu, 31 Mar 2011 10:03:03 GMT) (full text, mbox, link).
Added tag(s) moreinfo.
Request was from Matthias Klose <doko@debian.org>
to control@bugs.debian.org.
(Thu, 31 Mar 2011 10:03:03 GMT) (full text, mbox, link).
Information forwarded
to debian-bugs-dist@lists.debian.org, Debian GCC Maintainers <debian-gcc@lists.debian.org>:
Bug#619963; Package gcc-4.6.
(Sat, 02 Apr 2011 15:03:03 GMT) (full text, mbox, link).
Acknowledgement sent
to Török Edwin <edwintorok@gmail.com>:
Extra info received and forwarded to list. Copy sent to Debian GCC Maintainers <debian-gcc@lists.debian.org>.
(Sat, 02 Apr 2011 15:03:03 GMT) (full text, mbox, link).
Message #24 received at 619963@bugs.debian.org (full text, mbox, reply):
[Message part 1 (text/plain, inline)]
Hi,
Attached is a simple testcase from VLC.
At -O0 everything is fine:
$ gcc-4.6 -S -O0 x.i
$ grep memmove x.s
call __memmove_chk
At -O1 it incorrectly it is incorrectly changed to memcpy:
$ gcc-4.6 -S -O1 x.i
$ grep memcpy x.s
call memcpy
If I change the provided x.i, and remove the extern inline declaration
of memmove, then memmove is no longer changed to memcpy!
Also all is good with gcc-4.5:
$ gcc-4.5 -S -O2 x.i
$ grep memmove x.s
call memmove
Poking around in gcc-4.6 sources this place in gcc/builtins.c seems to
be the place where memmove_chk -> memcpy conversion happens, I didn't
verify that though:
if (fcode == BUILT_IN_MEMMOVE_CHK)
{
unsigned int src_align
= get_pointer_alignment (src, BIGGEST_ALIGNMENT);
if (src_align == 0)
return NULL_RTX;
/* If src is categorized for a readonly section we can use
normal __memcpy_chk. */
if (readonly_data_expr (src))
{
tree fn = built_in_decls[BUILT_IN_MEMCPY_CHK];
Best regards,
--Edwin
[x.i (text/plain, attachment)]
Information forwarded
to debian-bugs-dist@lists.debian.org, Debian GCC Maintainers <debian-gcc@lists.debian.org>:
Bug#619963; Package gcc-4.6.
(Sun, 03 Apr 2011 22:33:05 GMT) (full text, mbox, link).
Acknowledgement sent
to Marc Glisse <marc.glisse@inria.fr>:
Extra info received and forwarded to list. Copy sent to Debian GCC Maintainers <debian-gcc@lists.debian.org>.
(Sun, 03 Apr 2011 22:33:05 GMT) (full text, mbox, link).
Message #29 received at 619963@bugs.debian.org (full text, mbox, reply):
Hello,
in the prototype of memmove (taken from glibc bits/string3.h), you will
notice __restrict in front of the arguments. This is not present in more
recent glibc versions and is a likely cause of your trouble.
--
Marc Glisse
Information forwarded
to debian-bugs-dist@lists.debian.org, Debian GCC Maintainers <debian-gcc@lists.debian.org>:
Bug#619963; Package gcc-4.6.
(Sun, 10 Apr 2011 09:21:03 GMT) (full text, mbox, link).
Acknowledgement sent
to Török Edwin <edwintorok@gmail.com>:
Extra info received and forwarded to list. Copy sent to Debian GCC Maintainers <debian-gcc@lists.debian.org>.
(Sun, 10 Apr 2011 09:21:11 GMT) (full text, mbox, link).
Message #34 received at 619963@bugs.debian.org (full text, mbox, reply):
Marc Glisse wrote:
> Hello,
>
> in the prototype of memmove (taken from glibc bits/string3.h), you will
> notice __restrict in front of the arguments. This is not present in more
> recent glibc versions and is a likely cause of your trouble.
>
Indeed if I remove __restrict the bug is gone, and if I upgrade to libc6
2.13-0exp5, VLC's dec.c seems to be compiled correctly too.
Should gcc-4.6 depend on glibc >= 2.13?
Or should gcc-4.6 provide a fixed prototype for memmove via fix-includes?
Best regards,
--Edwin
Information forwarded
to debian-bugs-dist@lists.debian.org, Debian GCC Maintainers <debian-gcc@lists.debian.org>:
Bug#619963; Package gcc-4.6.
(Thu, 28 Apr 2011 21:54:03 GMT) (full text, mbox, link).
Acknowledgement sent
to Jonathan Nieder <jrnieder@gmail.com>:
Extra info received and forwarded to list. Copy sent to Debian GCC Maintainers <debian-gcc@lists.debian.org>.
(Thu, 28 Apr 2011 21:54:03 GMT) (full text, mbox, link).
Message #39 received at 619963@bugs.debian.org (full text, mbox, reply):
tags 619963 - moreinfo
quit
Hi,
Török Edwin wrote:
> Indeed if I remove __restrict the bug is gone, and if I upgrade to libc6
> 2.13-0exp5, VLC's dec.c seems to be compiled correctly too.
>
> Should gcc-4.6 depend on glibc >= 2.13?
> Or should gcc-4.6 provide a fixed prototype for memmove via fix-includes?
In other words, it is a libc6-dev bug, but it seems that gcc (<< 4.6) did
not expose it. I suppose that means gcc-4.6 could benefit from
Breaks: libc6-dev (<< fixed version), libc0.1-dev (<< fixed version),
libc0.3-dev (<< fixed version), libc6.1-dev (<< fixed version)
to force an upgrade. (Side note: it might make sense to rename those
packages to libc-dev and make libc<n>-dev into a dummy package.)
libc maintainers: any idea which versions mistakenly annotate memmove
with __restrict? Would that be worth fixing in stable (my hunch is
"yes")?
Thanks for tracking this down.
Jonathan
Removed tag(s) moreinfo.
Request was from Jonathan Nieder <jrnieder@gmail.com>
to control@bugs.debian.org.
(Thu, 28 Apr 2011 21:54:05 GMT) (full text, mbox, link).
Information forwarded
to debian-bugs-dist@lists.debian.org, Debian GCC Maintainers <debian-gcc@lists.debian.org>:
Bug#619963; Package gcc-4.6.
(Sun, 01 May 2011 14:45:02 GMT) (full text, mbox, link).
Acknowledgement sent
to Aurelien Jarno <aurelien@aurel32.net>:
Extra info received and forwarded to list. Copy sent to Debian GCC Maintainers <debian-gcc@lists.debian.org>.
(Sun, 01 May 2011 14:45:02 GMT) (full text, mbox, link).
Message #46 received at 619963@bugs.debian.org (full text, mbox, reply):
On Thu, Apr 28, 2011 at 04:50:15PM -0500, Jonathan Nieder wrote:
> tags 619963 - moreinfo
> quit
>
> Hi,
>
> Török Edwin wrote:
>
> > Indeed if I remove __restrict the bug is gone, and if I upgrade to libc6
> > 2.13-0exp5, VLC's dec.c seems to be compiled correctly too.
> >
> > Should gcc-4.6 depend on glibc >= 2.13?
> > Or should gcc-4.6 provide a fixed prototype for memmove via fix-includes?
>
> In other words, it is a libc6-dev bug, but it seems that gcc (<< 4.6) did
> not expose it. I suppose that means gcc-4.6 could benefit from
>
> Breaks: libc6-dev (<< fixed version), libc0.1-dev (<< fixed version),
> libc0.3-dev (<< fixed version), libc6.1-dev (<< fixed version)
>
> to force an upgrade. (Side note: it might make sense to rename those
> packages to libc-dev and make libc<n>-dev into a dummy package.)
>
> libc maintainers: any idea which versions mistakenly annotate memmove
> with __restrict? Would that be worth fixing in stable (my hunch is
> "yes")?
>
It's probably worth fixing that in stable, but I don't think we should
do an upload to stable just to fix that. I'll include a patch in the SVN
later, so that it's included in the next upload to stable.
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
Information forwarded
to debian-bugs-dist@lists.debian.org, Debian GCC Maintainers <debian-gcc@lists.debian.org>:
Bug#619963; Package gcc-4.6.
(Mon, 02 May 2011 00:39:05 GMT) (full text, mbox, link).
Acknowledgement sent
to Jonathan Nieder <jrnieder@gmail.com>:
Extra info received and forwarded to list. Copy sent to Debian GCC Maintainers <debian-gcc@lists.debian.org>.
(Mon, 02 May 2011 00:39:05 GMT) (full text, mbox, link).
Message #51 received at 619963@bugs.debian.org (full text, mbox, reply):
Aurelien Jarno wrote:
> It's probably worth fixing that in stable, but I don't think we should
> do an upload to stable just to fix that. I'll include a patch in the SVN
> later, so that it's included in the next upload to stable.
Thanks much. Makes sense.
Added tag(s) pending.
Request was from Aurelien Jarno <aurel32@alioth.debian.org>
to control@bugs.debian.org.
(Mon, 02 May 2011 04:39:03 GMT) (full text, mbox, link).
Bug reassigned from package 'gcc-4.6' to 'eglibc'.
Request was from Thomas Schwinge <thomas@schwinge.name>
to control@bugs.debian.org.
(Tue, 24 May 2011 09:54:26 GMT) (full text, mbox, link).
Bug No longer marked as found in versions gcc-4.6/4.6.0-1.
Request was from Thomas Schwinge <thomas@schwinge.name>
to control@bugs.debian.org.
(Tue, 24 May 2011 09:54:27 GMT) (full text, mbox, link).
Forcibly Merged 619963 624696 624743.
Request was from Thomas Schwinge <thomas@schwinge.name>
to control@bugs.debian.org.
(Tue, 24 May 2011 09:54:30 GMT) (full text, mbox, link).
Added indication that 619963 affects vlc and exim4
Request was from Thomas Schwinge <thomas@schwinge.name>
to control@bugs.debian.org.
(Tue, 24 May 2011 09:54:32 GMT) (full text, mbox, link).
Reply sent
to Aurelien Jarno <aurelien@aurel32.net>:
You have taken responsibility.
(Tue, 24 May 2011 11:06:09 GMT) (full text, mbox, link).
Notification sent
to Remi Denis-Courmont <remi@remlab.net>:
Bug acknowledged by developer.
(Tue, 24 May 2011 11:06:10 GMT) (full text, mbox, link).
Message #66 received at 619963-done@bugs.debian.org (full text, mbox, reply):
Version: 2.13-1
On Sun, Apr 10, 2011 at 12:18:43PM +0300, Török Edwin wrote:
> Marc Glisse wrote:
> > Hello,
> >
> > in the prototype of memmove (taken from glibc bits/string3.h), you will
> > notice __restrict in front of the arguments. This is not present in more
> > recent glibc versions and is a likely cause of your trouble.
> >
>
> Indeed if I remove __restrict the bug is gone, and if I upgrade to libc6
> 2.13-0exp5, VLC's dec.c seems to be compiled correctly too.
This bug has been fixed in eglibc 2.13-1. Closing the bug.
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
Reply sent
to Aurelien Jarno <aurelien@aurel32.net>:
You have taken responsibility.
(Tue, 24 May 2011 11:06:18 GMT) (full text, mbox, link).
Notification sent
to Andreas Metzler <ametzler@downhill.at.eu.org>:
Bug acknowledged by developer.
(Tue, 24 May 2011 11:06:25 GMT) (full text, mbox, link).
Reply sent
to Aurelien Jarno <aurelien@aurel32.net>:
You have taken responsibility.
(Tue, 24 May 2011 11:06:30 GMT) (full text, mbox, link).
Notification sent
to Andreas Metzler <ametzler@downhill.at.eu.org>:
Bug acknowledged by developer.
(Tue, 24 May 2011 11:06:37 GMT) (full text, mbox, link).
Bug reassigned from package 'eglibc' to 'libc6-dev'.
Request was from Jonathan Nieder <jrnieder@gmail.com>
to control@bugs.debian.org.
(Tue, 24 May 2011 17:57:06 GMT) (full text, mbox, link).
Bug No longer marked as fixed in versions 2.13-1.
Request was from Jonathan Nieder <jrnieder@gmail.com>
to control@bugs.debian.org.
(Tue, 24 May 2011 17:57:08 GMT) (full text, mbox, link).
Bug Marked as found in versions eglibc/2.11.2-10.
Request was from Jonathan Nieder <jrnieder@gmail.com>
to control@bugs.debian.org.
(Tue, 24 May 2011 17:57:10 GMT) (full text, mbox, link).
Bug Marked as fixed in versions eglibc/2.13-1.
Request was from Jonathan Nieder <jrnieder@gmail.com>
to control@bugs.debian.org.
(Tue, 24 May 2011 18:03:06 GMT) (full text, mbox, link).
Added tag(s) pending.
Request was from Jonathan Nieder <jrnieder@gmail.com>
to control@bugs.debian.org.
(Tue, 24 May 2011 18:03:08 GMT) (full text, mbox, link).
Added indication that 619963 affects gcc-4.6
Request was from Jonathan Nieder <jrnieder@gmail.com>
to control@bugs.debian.org.
(Tue, 24 May 2011 18:09:06 GMT) (full text, mbox, link).
Bug archived.
Request was from Debbugs Internal Request <owner@bugs.debian.org>
to internal_control@bugs.debian.org.
(Wed, 22 Jun 2011 07:35:43 GMT) (full text, mbox, link).
Bug unarchived.
Request was from Aurelien Jarno <aurel32@debian.org>
to control@bugs.debian.org.
(Fri, 12 Aug 2011 18:33:02 GMT) (full text, mbox, link).
Bug archived.
Request was from Debbugs Internal Request <owner@bugs.debian.org>
to internal_control@bugs.debian.org.
(Sat, 10 Sep 2011 07:37:27 GMT) (full text, mbox, link).
Send a report that this bug log contains spam.
Debian bug tracking system administrator <owner@bugs.debian.org>.
Last modified:
Wed Dec 6 15:09:46 2023;
Machine Name:
buxtehude
Debian Bug tracking system
Debbugs is free software and licensed under the terms of the GNU
Public License version 2. The current version can be obtained
from https://bugs.debian.org/debbugs-source/.
Copyright © 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson,
2005-2017 Don Armstrong, and many other contributors.