public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Sebor <msebor@gmail.com>
To: Eric Gallager <egall@gwmail.gwu.edu>, Martin Sebor <msebor@redhat.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH 2/2] add -Wdangling-pointer [PR #63272]
Date: Tue, 2 Nov 2021 12:38:18 -0600	[thread overview]
Message-ID: <bd53f41a-f568-b4f0-933f-5f28a4bebc90@gmail.com> (raw)
In-Reply-To: <CAMfHzOuFFd+9KcjXQaF18RMoev0xn-GXBQ9bLP3U=8J-SYorxA@mail.gmail.com>

On 11/2/21 1:40 AM, Eric Gallager wrote:
> On Mon, Nov 1, 2021 at 6:20 PM Martin Sebor via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>>
>> Patch 2 in this series adds support for detecting the uses of
>> dangling pointers: those to auto objects that have gone out of
>> scope.  Like patch 1, to minimize false positives this detection
>> is very simplistic.  However, thanks to the more deterministic
>> nature of the problem (all local objects go out of scope) is able
>> to detect more instances of it.  The approach I used is to simply
>> search the IL for clobbers that dominate uses of pointers to
>> the clobbered objects.  If such a use is found that's not
>> followed by a clobber of the same object the warning triggers.
>> Similar to -Wuse-after-free, the new -Wdangling-pointer option
>> has multiple levels: level 1 to detect unconditional uses and
>> level 2 to flag conditional ones.  Unlike with -Wuse-after-free
>> there is no use case for testing dangling pointers for
>> equality, so there is no level 3.
>>
>> Tested on x86_64-linux and  by building Glibc and Binutils/GDB.
>> It found no problems outside of the GCC test suite.
>>
>> As with the first patch in this series, the tests contain a number
>> of xfails due to known limitations marked with pr??????.  I'll
>> open bugs for them before committing the patch if I don't resolve
>> them first in a followup.
>>
>> Martin
> 
> So, I'd just like to take this chance to re-state my preference (as a
> user) for having separate named options for warnings instead of having
> a single option with multiple levels, so that users can toggle just
> one but not the other. With the numerical levels, one can detect only
> unconditional uses, and not conditional ones, by using level one, but
> they can't do it the other way around (i.e. detecting conditional
> uses, but not unconditional ones), though. I think having a split like
> the one that exists between -Wuninitialized and -Wmaybe-uninitialized
> would make sense here.

I agree that separate options are preferable for warnings with
different design strategies.  That said, I can't think of a use
case for enabling the "higher" level of either of any of our
warnings without also enabling the former.  Their sole purpose
is to control the S/R ratio, or perhaps also the cost in terms
of the compile-time resources spent on the analysis, though
I'm not aware of any measurements backing this up.

The distinction between levels 1 and 2 in the proposed warnings
is fairly subtle, and the higher level is by design exceedingly
unlikely to result in enough false positives to make lowering
it worthwhile.  It may not even be worth exposing a difference
between them via an option.   In fact, I think it might make
sense to merge them (perhaps keeping the "may" phrasing) unless
a compelling argument turns up in favor of keeping them distinct.

Martin

  reply	other threads:[~2021-11-02 18:38 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-01 22:15 [PATCH 0/2] provide simple detection of indeterminate pointers Martin Sebor
2021-11-01 22:17 ` [PATCH 1/2] add -Wuse-after-free Martin Sebor
2021-11-02  5:32   ` Eric Gallager
2021-11-02 17:09     ` Martin Sebor
2021-11-02 22:29   ` David Malcolm
2021-11-03  0:22     ` Martin Sebor
2021-11-23  1:32   ` Jeff Law
2021-11-23 21:16     ` Martin Sebor
2021-11-30 22:32       ` [PATCH v2 " Martin Sebor
2021-12-07  0:50         ` PING " Martin Sebor
2021-12-13 16:48           ` PING 2 " Martin Sebor
2022-01-04 18:01             ` PING 3 " Martin Sebor
2022-01-10 21:58               ` PING 4 " Martin Sebor
2022-01-11 22:40         ` Jason Merrill
2022-01-16  0:00           ` Martin Sebor
2022-03-26 20:35             ` Remove mysterious '-# Defining these options here in addition to common.opt is necessary' command-line option (was: [PATCH v2 1/2] add -Wuse-after-free) Thomas Schwinge
2022-03-29  9:24             ` options: Remove 'gcc/c-family/c.opt:Wuse-after-free' option definition record " Thomas Schwinge
2022-03-29 15:15               ` Martin Sebor
2022-03-29 18:00               ` Joseph Myers
2022-01-19 22:53           ` [PATCH v2 1/2] add -Wuse-after-free Jeff Law
2021-11-01 22:18 ` [PATCH 2/2] add -Wdangling-pointer [PR #63272] Martin Sebor
2021-11-02  7:40   ` Eric Gallager
2021-11-02 18:38     ` Martin Sebor [this message]
2021-11-30 22:55   ` [PATCH v2 " Martin Sebor
2021-12-07  0:51     ` PING " Martin Sebor
2021-12-13 16:50       ` PING 2 " Martin Sebor
2022-01-04 18:02         ` PING 3 " Martin Sebor
2022-01-10 21:51           ` PING 4 " Martin Sebor
2022-01-17 13:46             ` Stephan Bergmann
2022-01-17 19:14               ` Martin Sebor
2022-01-19 14:03                 ` Stephan Bergmann
2021-11-08 22:41 ` PING [PATCH 0/2] provide simple detection of indeterminate pointers Martin Sebor
2021-11-15 16:47   ` PING 2 " Martin Sebor
2021-11-22 16:41     ` PING 3 " Martin Sebor

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=bd53f41a-f568-b4f0-933f-5f28a4bebc90@gmail.com \
    --to=msebor@gmail.com \
    --cc=egall@gwmail.gwu.edu \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=msebor@redhat.com \
    /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).