public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/59125] New: [4.8 regression] gcc triggers wrong strncpy_chk
@ 2013-11-14  1:24 jengelh at inai dot de
  2013-11-14  9:34 ` [Bug middle-end/59125] [4.8/4.9 Regression] " rguenth at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: jengelh at inai dot de @ 2013-11-14  1:24 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 8328 bytes --]

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59125

            Bug ID: 59125
           Summary: [4.8 regression] gcc triggers wrong strncpy_chk
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jengelh at inai dot de

Given this compiler version/variant:

> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/4.8/lto-wrapper
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,obj-c++,java,ada
--enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.8
--enable-ssp --disable-libssp --disable-plugin
--with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux'
--disable-libgcj --disable-libmudflap --with-slibdir=/lib64 --with-system-zlib
--enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch
--enable-version-specific-runtime-libs --enable-linker-build-id
--enable-linux-futex --program-suffix=-4.8 --without-system-libunwind
--with-arch-32=i586 --with-tune=generic --build=x86_64-suse-linux
--host=x86_64-suse-linux
Thread model: posix
gcc version 4.8.2 20131016 [gcc-4_8-branch revision 203692] (SUSE Linux) 

and this source:

#include <string.h>
union u {
 struct {
  char vi[8];
  char pi[16];
 };
 char all[8+16+4];
};
void f(union u *u)
{
 char vi[8+1];
 char pi[16+1];
 strncpy(vi, u->vi, sizeof(u->vi));
 strncpy(pi, u->pi, sizeof(u->pi));
 strncpy(u->all, "AbcdefghAbcdefghijklmnopAbcd", sizeof(u->all));
}

I observe:

$ gcc-4.8 -O2 -D_FORTIFY_SOURCE=2 -c test.c
In file included from /usr/include/string.h:638:0,
                 from sci.c:1:
In function ‘strncpy’,
    inlined from ‘f’ at sci.c:15:9:
/usr/include/bits/string3.h:120:3: warning: call to __builtin___strncpy_chk
will always overflow destination buffer [enabled by default]
   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
   ^
$ gcc-4.7 -O2 -D_FORTIFY_SOURCE=2 -c sci.c
$ clang -O2 -D_FORTIFY_SOURCE=2 -c sci.c

I would have expected:

gcc-4.8 to do as gcc-4.7 did and remain silent. I cannot see anything wrong
with the strncpy lines…
>From gcc-bugs-return-434540-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Nov 14 01:44:08 2013
Return-Path: <gcc-bugs-return-434540-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 26646 invoked by alias); 14 Nov 2013 01:44:07 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 26625 invoked by uid 48); 14 Nov 2013 01:44:04 -0000
From: "adam at wozniakconsulting dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/59126] New: internal compiler error: Segmentation fault
Date: Thu, 14 Nov 2013 01:44:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c
X-Bugzilla-Version: 4.6.3
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: adam at wozniakconsulting dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created
Message-ID: <bug-59126-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-11/txt/msg01317.txt.bz2
Content-length: 4056

http://gcc.gnu.org/bugzilla/show_bug.cgi?idY126

            Bug ID: 59126
           Summary: internal compiler error: Segmentation fault
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: adam at wozniakconsulting dot com

Created attachment 31214
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id1214&actioníit
preprocessed source

$ lsb_release -a
LSB Version:
core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-noarch:cxx-3.0-amd64:cxx-3.0-noarch:cxx-3.1-amd64:cxx-3.1-noarch:cxx-3.2-amd64:cxx-3.2-noarch:cxx-4.0-amd64:cxx-4.0-noarch:desktop-3.1-amd64:desktop-3.1-noarch:desktop-3.2-amd64:desktop-3.2-noarch:desktop-4.0-amd64:desktop-4.0-noarch:graphics-2.0-amd64:graphics-2.0-noarch:graphics-3.0-amd64:graphics-3.0-noarch:graphics-3.1-amd64:graphics-3.1-noarch:graphics-3.2-amd64:graphics-3.2-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-3.2-amd64:printing-3.2-noarch:printing-4.0-amd64:printing-4.0-noarch:qt4-3.1-amd64:qt4-3.1-noarch
Distributor ID:    Ubuntu
Description:    Ubuntu 12.04.3 LTS
Release:    12.04
Codename:    precise

$ x86_64-linux-gnu-gcc --version
x86_64-linux-gnu-gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

make[2]: Entering directory
`/home/awozniak/work/firstlook/thermal/toolchain/build/build-mpfr/src'
/bin/sh ../libtool --tagÌ   --mode=compile x86_64-linux-gnu-gcc -std=gnu99
-DTIME_WITH_SYS_TIME=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_LOCALE_H=1
-DHAVE_WCHAR_H=1 -DHAVE_STDARG=1 -DHAVE_SYS_TIME_H=1 -DHAVE_ALLOCA_H=1
-DHAVE_STDINT_H=1 -DHAVE_VA_COPY=1 -DHAVE_SETLOCALE=1 -DHAVE_GETTIMEOFDAY=1
-DHAVE_LONG_LONG=1 -DHAVE_INTMAX_T=1 -DMPFR_HAVE_INTMAX_MAX=1
-DMPFR_HAVE_FESETROUND=1 -DHAVE_DENORMS=1 -DHAVE_ROUND=1 -DHAVE_TRUNC=1
-DHAVE_FLOOR=1 -DHAVE_CEIL=1 -DHAVE_NEARBYINT=1
-DHAVE_LDOUBLE_IEEE_EXT_LITTLE=1 -DMPFR_USE_THREAD_SAFE=1
-DHAVE_CLOCK_GETTIME=1 -DLT_OBJDIR=\".libs/\" -DHAVE_ATTRIBUTE_MODE=1
-DHAVE___GMPN_ROOTREM=1 -DHAVE___GMPN_SBPI1_DIVAPPR_Q=1 -I.
-I../../mpfr-3.1.2/src     -Wall -Wmissing-prototypes -Wpointer-arith -Wall -g
-O3 -MT set_f.lo -MD -MP -MF .deps/set_f.Tpo -c -o set_f.lo
../../mpfr-3.1.2/src/set_f.c
libtool: compile:  x86_64-linux-gnu-gcc -std=gnu99 -DTIME_WITH_SYS_TIME=1
-DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_LOCALE_H=1 -DHAVE_WCHAR_H=1
-DHAVE_STDARG=1 -DHAVE_SYS_TIME_H=1 -DHAVE_ALLOCA_H=1 -DHAVE_STDINT_H=1
-DHAVE_VA_COPY=1 -DHAVE_SETLOCALE=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_LONG_LONG=1
-DHAVE_INTMAX_T=1 -DMPFR_HAVE_INTMAX_MAX=1 -DMPFR_HAVE_FESETROUND=1
-DHAVE_DENORMS=1 -DHAVE_ROUND=1 -DHAVE_TRUNC=1 -DHAVE_FLOOR=1 -DHAVE_CEIL=1
-DHAVE_NEARBYINT=1 -DHAVE_LDOUBLE_IEEE_EXT_LITTLE=1 -DMPFR_USE_THREAD_SAFE=1
-DHAVE_CLOCK_GETTIME=1 -DLT_OBJDIR=\".libs/\" -DHAVE_ATTRIBUTE_MODE=1
-DHAVE___GMPN_ROOTREM=1 -DHAVE___GMPN_SBPI1_DIVAPPR_Q=1 -I.
-I../../mpfr-3.1.2/src -Wall -Wmissing-prototypes -Wpointer-arith -Wall -g -O3
-MT set_f.lo -MD -MP -MF .deps/set_f.Tpo -c ../../mpfr-3.1.2/src/set_f.c  -fPIC
-DPIC -o .libs/set_f.o
../../mpfr-3.1.2/src/set_f.c: In function 'mpfr_set_f':
../../mpfr-3.1.2/src/set_f.c:27:1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
Preprocessed source stored into /tmp/ccrVWU7l.out file, please attach this to
your bugreport.
make[2]: *** [set_f.lo] Error 1
make[2]: Leaving directory
`/home/awozniak/work/firstlook/thermal/toolchain/build/build-mpfr/src'
make[1]: *** [all] Error 2
make[1]: Leaving directory
`/home/awozniak/work/firstlook/thermal/toolchain/build/build-mpfr/src'
make: *** [all-recursive] Error 1


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

end of thread, other threads:[~2014-01-09 15:30 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-14  1:24 [Bug c/59125] New: [4.8 regression] gcc triggers wrong strncpy_chk jengelh at inai dot de
2013-11-14  9:34 ` [Bug middle-end/59125] [4.8/4.9 Regression] " rguenth at gcc dot gnu.org
2013-11-14  9:42 ` rguenth at gcc dot gnu.org
2013-11-14 12:59 ` rguenth at gcc dot gnu.org
2013-11-15 13:37 ` rguenth at gcc dot gnu.org
2013-11-15 13:39 ` rguenth at gcc dot gnu.org
2013-11-18 15:25 ` rguenth at gcc dot gnu.org
2013-11-18 15:27 ` [Bug middle-end/59125] [4.8 " rguenth at gcc dot gnu.org
2013-12-03  7:49 ` jakub at gcc dot gnu.org
2014-01-08 13:49 ` rafal at rawicki dot org
2014-01-08 14:05 ` rguenth at gcc dot gnu.org
2014-01-09 15:25 ` rguenth at gcc dot gnu.org
2014-01-09 15:30 ` rguenth at gcc dot gnu.org

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).