public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "hjl.tools at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/50460] New: [4.7 Regression] __builtin___strcpy_chk/__builtin_object_size don't work Date: Tue, 20 Sep 2011 08:16:00 -0000 [thread overview] Message-ID: <bug-50460-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50460 Bug #: 50460 Summary: [4.7 Regression] __builtin___strcpy_chk/__builtin_object_size don't work Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned@gcc.gnu.org ReportedBy: hjl.tools@gmail.com On Linux/x86, revision 178028 gave [hjl@gnu-34 gcc]$ cat ~/tmp/foo.c const char *str1 = "JIHGFEDCBA"; extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) char * __attribute__ ((__nothrow__)) strcpy (char *__restrict __dest, __const char *__restrict __src) { return __builtin___strcpy_chk (__dest, __src, __builtin_object_size (__dest, 2 > 1)); } int main () { struct A { char buf1[9]; char buf2[1]; } a; strcpy (a.buf1 + (0 + 4), str1 + 5); return 0; } [hjl@gnu-34 gcc]$ ./xgcc -B./ -O2 ~/tmp/foo.c [hjl@gnu-34 gcc]$ ./a.out [hjl@gnu-34 gcc]$ instead of [hjl@gnu-34 gcc]$ ./a.out *** buffer overflow detected ***: ./a.out terminated ======= Backtrace: ========= /lib64/libc.so.6(__fortify_fail+0x37)[0x3e56103ca7] /lib64/libc.so.6[0x3e56101c20] ./a.out[0x40041e] /lib64/libc.so.6(__libc_start_main+0xed)[0x3e560215bd] ./a.out[0x400451] ======= Memory map: ======== 00400000-00401000 r-xp 00000000 08:11 52433950 /export/gnu/import/svn/gcc-test-ia32corei7/bld/gcc/a.out 00600000-00601000 rw-p 00000000 08:11 52433950 /export/gnu/import/svn/gcc-test-ia32corei7/bld/gcc/a.out 00a33000-00a54000 rw-p 00000000 00:00 0 [heap] 3e55c00000-3e55c22000 r-xp 00000000 08:06 392457 /lib64/ld-2.14.90.so 3e55e21000-3e55e22000 r--p 00021000 08:06 392457 /lib64/ld-2.14.90.so 3e55e22000-3e55e23000 rw-p 00022000 08:06 392457 /lib64/ld-2.14.90.so 3e55e23000-3e55e24000 rw-p 00000000 00:00 0 3e56000000-3e561a6000 r-xp 00000000 08:06 392458 /lib64/libc-2.14.90.so 3e561a6000-3e563a5000 ---p 001a6000 08:06 392458 /lib64/libc-2.14.90.so 3e563a5000-3e563a9000 r--p 001a5000 08:06 392458 /lib64/libc-2.14.90.so 3e563a9000-3e563aa000 rw-p 001a9000 08:06 392458 /lib64/libc-2.14.90.so 3e563aa000-3e563b0000 rw-p 00000000 00:00 0 3e57800000-3e57815000 r-xp 00000000 08:06 392602 /lib64/libgcc_s-4.6.0-20110603.so.1 3e57815000-3e57a14000 ---p 00015000 08:06 392602 /lib64/libgcc_s-4.6.0-20110603.so.1 3e57a14000-3e57a15000 rw-p 00014000 08:06 392602 /lib64/libgcc_s-4.6.0-20110603.so.1 7fb292f73000-7fb292f76000 rw-p 00000000 00:00 0 7fb292f93000-7fb292f95000 rw-p 00000000 00:00 0 7fff0d60a000-7fff0d62b000 rw-p 00000000 00:00 0 [stack] 7fff0d68a000-7fff0d68b000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall] Aborted (core dumped) [hjl@gnu-34 gcc]$ Revision 177983 is OK.
next reply other threads:[~2011-09-20 5:20 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-09-20 8:16 hjl.tools at gmail dot com [this message] 2011-09-20 10:49 ` [Bug middle-end/50460] " jakub at gcc dot gnu.org 2011-09-20 13:47 ` hjl.tools at gmail dot com 2011-09-22 22:06 ` rguenth at gcc dot gnu.org 2011-09-23 8:34 ` jakub at gcc dot gnu.org 2011-09-25 11:24 ` rguenth at gcc dot gnu.org 2011-09-26 9:14 ` jakub at gcc dot gnu.org 2011-09-28 12:29 ` rguenth at gcc dot gnu.org 2011-09-28 13:52 ` rguenth at gcc dot gnu.org 2011-09-28 14:01 ` rguenth at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-50460-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).