public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "amacleod at redhat dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/111009] [12/13/14 regression] -fno-strict-overflow erroneously elides null pointer checks and causes SIGSEGV on perf from linux-6.4.10
Date: Tue, 15 Aug 2023 17:57:13 +0000	[thread overview]
Message-ID: <bug-111009-4-hWNpSZtkTm@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-111009-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111009

--- Comment #4 from Andrew Macleod <amacleod at redhat dot com> ---
(In reply to Richard Biener from comment #3)
> bool
> operator_addr_expr::fold_range (irange &r, tree type,
>                                 const irange &lh,
>                                 const irange &rh,
>                                 relation_trio) const
> { 
>   if (empty_range_varying (r, type, lh, rh))
>     return true;
>   
>   // Return a non-null pointer of the LHS type (passed in op2).
>   if (lh.zero_p ())
>     r = range_zero (type); 
> 
> not sure how this is called, but we can only derive this if the offset
> is zero as well, definitely if targetm.addr_space.zero_address_valid,
> but I think this is true in general.
> 
>   else if (!contains_zero_p (lh))
>     r = range_nonzero (type);
> 
> and this is only true for TYPE_OVERFLOW_UNDEFINED (type), with
> -fwrapv-pointer we could wrap to zero.
> 
> That is, it's _not_ GIMPLE undefined behavior to compute &0->bar.


> It looks like without -fwrapv-pointer we elide the if (!a) check,
> dereferencing it when dso && dso != curr.  I suppose that looks reasonable
> with a = &dso->maj, when dso != 0 then a != 0 unless ->maj wraps.

Range-ops won't see anything like &dso->maj.. it sees rangers and nothing else.
it just gets the result of that expression determined by someone else. . so if
it see [0,0] for the range, that means &dso->maj has been determined to be 0.

When folding, addressof has some funky mechanics, and it symbolically processes
the trees in gimple-range-fold.cc  in fold_using_range::range_of_address

I think it takes care of all the funky things you mention.

I also notice in the earlier comment where we set _13 to 0...   the code you
quoted where _13 was recomputed by ranger. it ends with   
   GORI  TRUE : (797) recomputation (_13) [irange] _Bool [1, 1]
The result was [1,1] as far as ranger was concerned o the edge from 3->16
so that prop0bably isn't how gimple fold determined it was zero.

Is there still an issue here?

  parent reply	other threads:[~2023-08-15 17:57 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-14  8:26 [Bug middle-end/111009] New: " slyfox at gcc dot gnu.org
2023-08-14  9:34 ` [Bug middle-end/111009] " amonakov at gcc dot gnu.org
2023-08-14 11:34 ` rguenth at gcc dot gnu.org
2023-08-14 11:48 ` rguenth at gcc dot gnu.org
2023-08-15 17:57 ` amacleod at redhat dot com [this message]
2023-08-16 20:14 ` slyfox at gcc dot gnu.org
2023-08-16 20:21 ` sjames at gcc dot gnu.org
2023-08-16 20:40 ` slyfox at gcc dot gnu.org
2023-08-16 21:05 ` amacleod at redhat dot com
2023-08-16 21:24 ` slyfox at gcc dot gnu.org
2023-08-17 15:37 ` amacleod at redhat dot com
2023-08-17 17:39 ` cvs-commit at gcc dot gnu.org
2023-08-17 19:44 ` slyfox at gcc dot gnu.org
2024-05-08 12:03 ` [Bug middle-end/111009] [12/13 " rguenth at gcc dot gnu.org
2024-05-08 18:26 ` amacleod at redhat dot com
2024-05-09 14:32 ` cvs-commit at gcc dot gnu.org
2024-05-10  6:36 ` [Bug middle-end/111009] [12 " rguenth at gcc dot gnu.org
2024-05-13 17:49 ` cvs-commit at gcc dot gnu.org
2024-06-12 11:38 ` 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-111009-4-hWNpSZtkTm@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).