public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Tim Lange <mail@tim-lange.me>
Cc: gcc@gcc.gnu.org
Subject: Re: [PATCH v3] analyzer: add allocation size checker [PR105900]
Date: Thu, 30 Jun 2022 18:47:27 -0400	[thread overview]
Message-ID: <0a42edcea3f98879b6e480f79cc97900b1d80732.camel@redhat.com> (raw)
In-Reply-To: <20220630221153.49510-1-mail@tim-lange.me>

On Fri, 2022-07-01 at 00:11 +0200, Tim Lange wrote:
> Hi,
> 
> here's the updated patch that should address all the comments from the
> v2.
> 
> - Tim
> 
> This patch adds an checker that warns about code paths in which a
> buffer is
> assigned to a incompatible type, i.e. when the allocated buffer size is
> not a
> multiple of the pointee's size.
> 
> 2022-07-30  Tim Lange  <mail@tim-lange.me>
> 
> gcc/analyzer/ChangeLog:
> 
>         PR analyzer/105900
>         * analyzer.opt: Added Wanalyzer-allocation-size.
>         * checker-path.cc (region_creation_event::get_desc): Added call
> to new
>         virtual function
> pending_diagnostic::describe_region_creation_event.
>         * checker-path.h: Added region_creation_event::get_desc.
>         * diagnostic-manager.cc
> (diagnostic_manager::add_event_on_final_node):
>         New function.
>         * diagnostic-manager.h:
>         Added diagnostic_manager::add_event_on_final_node.
>         * pending-diagnostic.h (struct region_creation): New event_desc
> struct.
>         (pending_diagnostic::describe_region_creation_event): Added
> virtual
>         function to overwrite description of a region creation.
>         * region-model.cc (class dubious_allocation_size): New class.
>         (capacity_compatible_with_type): New helper function.
>         (class size_visitor): New class.
>         (struct_or_union_with_inheritance_p): New helper function.
>         (is_any_cast_p): New helper function.
>         (region_model::check_region_size): New function.
>         (region_model::set_value): Added call to
>         region_model::check_region_size.
>         * region-model.h (class region_model): New function
> check_region_size.
>         * svalue.cc (region_svalue::accept): Changed to post-order
> traversal.
>         (initial_svalue::accept): Likewise.
>         (unaryop_svalue::accept): Likewise.
>         (binop_svalue::accept): Likewise.
>         (sub_svalue::accept): Likewise.
>         (repeated_svalue::accept): Likewise.
>         (bits_within_svalue::accept): Likewise.
>         (widening_svalue::accept): Likewise.
>         (unmergeable_svalue::accept): Likewise.
>         (compound_svalue::accept): Likewise.
>         (conjured_svalue::accept): Likewise.
>         (asm_output_svalue::accept): Likewise.
>         (const_fn_result_svalue::accept): Likewise.
> 
> gcc/ChangeLog:
> 
>         PR analyzer/105900
>         * doc/invoke.texi: Added Wanalyzer-allocation-size.
> 
> gcc/testsuite/ChangeLog:
> 
>         PR analyzer/105900
> * gcc.dg/analyzer/pr96639.c: Changed buffer size to omit warning.
>         * gcc.dg/analyzer/allocation-size-1.c: New test.
>         * gcc.dg/analyzer/allocation-size-2.c: New test.
>         * gcc.dg/analyzer/allocation-size-3.c: New test.
>         * gcc.dg/analyzer/allocation-size-4.c: New test.
>         * gcc.dg/analyzer/allocation-size-5.c: New test.
> 
> Signed-off-by: Tim Lange <mail@tim-lange.me>


Thanks for the v3 patch.

Content-wise, the v3 patch looks ready to me, though there's something
weird with the formatting of the ChangeLog entry for pr96639.c in the
commit message - does the patch pass:
  ./contrib/gcc-changelog/git_check_commit.py HEAD
?  (this script gets run server-side on our git repository, and it
won't let you push a patch unless the script passes)

You didn't specify to what extent you've tested it.  If you've
successfully bootstrapped gcc with this patch applied, and run the test
suite with no regressions, then this is OK to push to trunk.

[...snip...]

Thanks
Dave



      reply	other threads:[~2022-06-30 22:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-17 15:54 [RFC] analyzer: allocation size warning Tim Lange
2022-06-17 17:15 ` Prathamesh Kulkarni
2022-06-17 19:23   ` Tim Lange
2022-06-17 21:39     ` David Malcolm
2022-06-17 17:48 ` David Malcolm
2022-06-17 20:23   ` Tim Lange
2022-06-17 22:13     ` David Malcolm
2022-06-21 20:00       ` Tim Lange
2022-06-21 23:16         ` David Malcolm
2022-06-22 14:57           ` Tim Lange
2022-06-22 18:23             ` David Malcolm
2022-06-17 18:34 ` [RFC] analyzer: add " Tim Lange
2022-06-29 15:39 ` [PATCH v2] analyzer: add allocation size checker Tim Lange
2022-06-29 17:39   ` David Malcolm
2022-06-30 20:40     ` Tim Lange
2022-06-30 22:11 ` [PATCH v3] analyzer: add allocation size checker [PR105900] Tim Lange
2022-06-30 22:47   ` David Malcolm [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=0a42edcea3f98879b6e480f79cc97900b1d80732.camel@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=mail@tim-lange.me \
    /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).