public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "marxin at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/108817] ASAN at -O3 failed to detect a global-buffer-overflow Date: Fri, 17 Feb 2023 14:31:21 +0000 [thread overview] Message-ID: <bug-108817-4-tQVcVqHXJG@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-108817-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108817 Martin Liška <marxin at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> --- Here we prove that 'return c' only depends on the last execution of 'c = b[a+1];' which is going to happen with a == 0 and thus we optimize out that. $ gcc pr108817.C -fsanitize=address -O3 -fdump-tree-optimized=/dev/stdout int main () { signed char _4; unsigned long _8; int _12; unsigned long _15; bool _16; unsigned long _18; int _19; char _20; bool _21; signed char _22; signed char _23; unsigned long _25; signed char * _27; bool _38; <bb 2> [local count: 26541933]: a = 2; _15 = (unsigned long) &MEM <int> [(void *)&b + 4B]; (checking if &b + 4 is valid in shadow memory) if (_16 != 0) goto <bb 3>; [0.05%] else goto <bb 4>; [99.95%] <bb 3> [local count: 13271]: __builtin___asan_report_load4 (_15); <bb 4> [local count: 26541933]: _19 = b[1]; <- here we use it as the future value _20 = (char) _19; c = _20; a = -1; _12 = (int) _20; return _12; } Final note: note clang does not report the issue even with -O1.
prev parent reply other threads:[~2023-02-17 14:31 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-02-16 8:16 [Bug sanitizer/108817] New: " shaohua.li at inf dot ethz.ch 2023-02-17 14:31 ` marxin at gcc dot gnu.org [this message]
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-108817-4-tQVcVqHXJG@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).