public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/94187] [10 Regression] valgrind error in count_nonzero_bytes since r10-2101 Date: Tue, 17 Mar 2020 09:44:27 +0000 [thread overview] Message-ID: <bug-94187-4-VJ4xphBKSL@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-94187-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94187 --- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:741ff2a263fe0ddc343288331c0047c1a32af8b2 commit r10-7207-g741ff2a263fe0ddc343288331c0047c1a32af8b2 Author: Jakub Jelinek <jakub@redhat.com> Date: Tue Mar 17 10:43:46 2020 +0100 strlen: Punt on UB reads past end of string literal [PR94187] The gcc.dg/pr68785.c test which contains: int foo (void) { return *(int *) ""; } has UB in the program if it is ever called, but causes UB in the compiler as well as at least in theory non-reproduceable code generation. The problem is that nbytes is in this case 4, prep is the TREE_STRING_POINTER of a "" string literal with TREE_STRING_LENGTH of 1 and we do: 4890 for (const char *p = prep; p != prep + nbytes; ++p) 4891 if (*p) 4892 { 4893 *allnul = false; 4894 break; 4895 } and so read the bytes after the STRING_CST payload, which can be random. I think we should just punt in this case. 2020-03-17 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/94187 * tree-ssa-strlen.c (count_nonzero_bytes): Punt if nchars - offset < nbytes.
next prev parent reply other threads:[~2020-03-17 9:44 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-03-16 8:10 [Bug c/94187] New: valgrind error in count_nonzero_bytes ? dcb314 at hotmail dot com 2020-03-16 10:51 ` [Bug tree-optimization/94187] " marxin at gcc dot gnu.org 2020-03-16 11:18 ` dcb314 at hotmail dot com 2020-03-16 11:20 ` jakub at gcc dot gnu.org 2020-03-16 11:28 ` jakub at gcc dot gnu.org 2020-03-16 11:35 ` [Bug tree-optimization/94187] [10 Regression] valgrind error in count_nonzero_bytes since r10-2101 jakub at gcc dot gnu.org 2020-03-16 11:40 ` jakub at gcc dot gnu.org 2020-03-16 12:07 ` dcb314 at hotmail dot com 2020-03-16 21:04 ` dcb314 at hotmail dot com 2020-03-17 8:38 ` marxin at gcc dot gnu.org 2020-03-17 8:52 ` dcb314 at hotmail dot com 2020-03-17 9:44 ` cvs-commit at gcc dot gnu.org [this message] 2020-03-17 9:54 ` jakub at gcc dot gnu.org 2020-03-25 16:08 ` dcb314 at hotmail dot com
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-94187-4-VJ4xphBKSL@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).