public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "shaohua.li at inf dot ethz.ch" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/108060] New: UBsan missed an out-of-bound bug at -O0 Date: Sun, 11 Dec 2022 14:32:29 +0000 [thread overview] Message-ID: <bug-108060-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108060 Bug ID: 108060 Summary: UBsan missed an out-of-bound bug at -O0 Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: shaohua.li at inf dot ethz.ch CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org, jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at gcc dot gnu.org Target Milestone: --- For the following code, UBsan at -O0 missed reporting the out-of-bound access, while -O1 and above caught it. Clang could detect it at all optimization levels. Compiler explorer: https://godbolt.org/z/Tb9Mern7M % cat a.c int a[8]; short b; char c; int main() { b = -32768; a[b] |= c; } % % gcc-tk -O0 -fsanitize=undefined -fno-sanitize-recover=all a.c && ./a.out Segmentation fault % gcc-tk -O1 -fsanitize=undefined -fno-sanitize-recover=all a.c && ./a.out a.c:6:4: runtime error: index -32768 out of bounds for type 'int [8]' % Interestingly, if you don't use `-fno-sanitize-recover=all`, none of opt levels could detect it: % gcc-tk -O1 -fsanitize=undefined a.c && ./a.out Segmentation fault %
next reply other threads:[~2022-12-11 14:32 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-12-11 14:32 shaohua.li at inf dot ethz.ch [this message] 2022-12-12 12:45 ` [Bug sanitizer/108060] UBsan missed an out-of-bound bug at -O0 since r7-1900-g8a1b7b7fd75a3847 marxin at gcc dot gnu.org 2022-12-12 16:29 ` [Bug sanitizer/108060] [10/11/12/13 Regression] " pinskia at gcc dot gnu.org 2022-12-21 11:52 ` [Bug c/108060] " rguenth at gcc dot gnu.org 2022-12-22 12:06 ` marxin at gcc dot gnu.org 2023-03-07 14:29 ` marxin at gcc dot gnu.org 2023-03-07 14:30 ` marxin at gcc dot gnu.org 2023-03-07 14:44 ` mpolacek at gcc dot gnu.org 2023-03-07 23:19 ` mpolacek at gcc dot gnu.org 2023-03-10 18:25 ` [Bug sanitizer/108060] " cvs-commit at gcc dot gnu.org 2023-03-10 18:32 ` [Bug sanitizer/108060] [10/11/12 " mpolacek at gcc dot gnu.org 2023-03-15 18:35 ` cvs-commit at gcc dot gnu.org 2023-03-15 18:35 ` [Bug sanitizer/108060] [10/11 " mpolacek at gcc dot gnu.org 2024-02-01 9:53 ` pinskia 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-108060-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).