public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "y.gribov at samsung dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug sanitizer/60861] out of bounds access of  global var in .rodata/.bss not detected
Date: Thu, 17 Apr 2014 06:32:00 -0000	[thread overview]
Message-ID: <bug-60861-4-M4KmLwjMEv@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-60861-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from Yury Gribov <y.gribov at samsung dot com> ---
(In reply to Andrew Pinski from comment #4)
> (In reply to Yury Gribov from comment #3)
> > I can reproduce this in trunk. Looks like Asan pass works correctly but gcc
> > reduces test() to 'return 1;' very early for some reason. I'll debug further.
> 
> Most likely due to GCC optimizing the code as it knows the only value it
> could be is 1.

Yup, testGlobalOutOfBoundsRODATAVar[depth] is cynically folded to 1 right in
the gimplifier:

 #0  fold_array_ctor_reference (type=0x7ffff6c93000, ctor=0x7ffff6c7ae28,
offset=0, size=32, from_decl=0x7ffff6c91098) at
/home/ygribov/src/gcc-master/gcc/gimple-fold.c:2994
 #1  0x00000000007fbc4b in fold_ctor_reference (type=0x7ffff6c93000,
ctor=0x7ffff6c7ae28, offset=0, size=32, from_decl=0x7ffff6c91098) at
/home/ygribov/src/gcc-master/gcc/gimple-fold.c:3124
 #2  0x00000000007fc1b4 in fold_const_aggregate_ref_1 (t=0x7ffff6c35188,
valueize=0) at /home/ygribov/src/gcc-master/gcc/gimple-fold.c:3226
 #3  0x00000000007fc2d7 in fold_const_aggregate_ref (t=0x7ffff6c35188) at
/home/ygribov/src/gcc-master/gcc/gimple-fold.c:3248
 #4  0x00000000007f2478 in maybe_fold_reference (expr=0x7ffff6c35188,
is_lhs=false) at /home/ygribov/src/gcc-master/gcc/gimple-fold.c:310
 #5  0x00000000007f2957 in fold_gimple_assign (si=0x7fffffffd1f0) at
/home/ygribov/src/gcc-master/gcc/gimple-fold.c:377
 #6  0x00000000007f57a2 in fold_stmt_1 (gsi=0x7fffffffd1f0, inplace=false) at
/home/ygribov/src/gcc-master/gcc/gimple-fold.c:1281
 #7  0x00000000007f5eba in fold_stmt (gsi=0x7fffffffd1f0) at
/home/ygribov/src/gcc-master/gcc/gimple-fold.c:1409
 #8  0x00000000008115d1 in maybe_fold_stmt (gsi=0x7fffffffd1f0) at
/home/ygribov/src/gcc-master/gcc/gimplify.c:2224
 #9  0x000000000081af78 in gimplify_modify_expr (expr_p=0x7fffffffd4a8,
pre_p=0x7fffffffd760, post_p=0x7fffffffd330, want_value=false) at
/home/ygribov/src/gcc-master/gcc/gimplify.c:4620
 #10 0x0000000000826bf4 in gimplify_expr (expr_p=0x7fffffffd4a8,
pre_p=0x7fffffffd760, post_p=0x7fffffffd330, gimple_test_f=0x819e8b
<is_gimple_stmt(tree)>, fallback=0) at
/home/ygribov/src/gcc-master/gcc/gimplify.c:7479

This kind of makes sense (although this optimization will break in presence of
LD_PRELOAD or weak symbols). In any case optimizations like this are typical
for gcc so I'm not sure there's a chance for a fix.


  parent reply	other threads:[~2014-04-17  6:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-16 15:17 [Bug sanitizer/60861] New: " jan.smets@alcatel-lucent.com
2014-04-16 19:02 ` [Bug sanitizer/60861] " kcc at gcc dot gnu.org
2014-04-16 21:33 ` jan.smets@alcatel-lucent.com
2014-04-17  5:00 ` y.gribov at samsung dot com
2014-04-17  5:04 ` pinskia at gcc dot gnu.org
2014-04-17  6:32 ` y.gribov at samsung dot com [this message]
2014-04-17  8:30 ` kcc at gcc dot gnu.org
2014-04-17  9:13 ` jakub 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-60861-4-M4KmLwjMEv@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: link
Be 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).