public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Sebor <msebor@gmail.com>
To: Jeff Law <law@redhat.com>, Gcc Patch List <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] enable -Wformat-length for dynamically allocated buffers (pr 78245)
Date: Wed, 23 Nov 2016 20:09:00 -0000	[thread overview]
Message-ID: <c81b61ce-1ce7-c33a-7153-36d9274887f1@gmail.com> (raw)
In-Reply-To: <d1bce6e0-3dee-be9e-6300-dfc8ebb33fd1@redhat.com>

On 11/23/2016 12:47 PM, Jeff Law wrote:
> On 11/23/2016 12:32 PM, Martin Sebor wrote:
>
>>> My worry here would be a hash collision.  Then we'd be using object
>>> sizes from the wrong function.
>>
>> Ah, right, that might explain the ICE I just noticed during Ada
>> bootstrap.  Is there some other way to uniquely identify a function?
>> A DECL_UID maybe?
> DECL_UID would be your best bet.  But ISTM that trying to avoid
> invocations by reusing data from prior passes is likely to be more
> fragile than recomputing on a per-pass basis -- as long as the number of
> times we need this stuff is small (as I suspect it is).
>
>>
>>>
>>> Isn't the goal here to be able to get format-length warnings when there
>>> aren't explicit calls to _b_o_s in the IL?   Can't you initialize the
>>> object-size framework at the start of your pass and tear it down when
>>> your pass is complete?  You could do that by exporting the init/fini
>>> routines and calling them directly, or by wrapping that in a class and
>>> instantiating the class when you need it.
>>>
>>> That would avoid having to worry about the GC system entirely since you
>>> wouldn't have stuff living across passes.
>>
>> Yes, that is the immediate goal of this patch.  Beyond it, though,
>> I would like to call this function from anywhere, including during
>> expansion (as is done in my patch for bug 53562 and related).
> But why not detect the builtins during your pass and check there.  ie, I
> don't see why we necessarily need to have checking and expansion
> intertwined together.  Maybe I'm missing something.  Is there something
> that makes it inherently easier or better to implement checking during
> builtin expansion?

I hadn't thought of extending the gimple-ssa-sprintf pass to all
the memxxx and strxxx builtins.  The _chk functions are already
being handled in builtins.c so calling compute_builtin_object_size
for the non-checking ones there and detecting overflow in those
was an easy and, I had hoped, non-controversial enhancement to make.
In a discussion of bug 77784 (handled in the patch for bug 53562)
Jakub also expressed a preference for some of the diagnostics
staying in builtins.c.

I also suspect that the answer to your question is yes.  Range
information is pretty bad in the gimple-ssa-sprintf pass (it looks
like it runs after EVRP but before VRP).  Maybe the pass should run
after VRP?

That said, I defer to you on how to proceed here.  I'm prepared
to do the work(*) but I do worry about jeopardizing the chances
of this patch and the others making it into 7.0.

Martin

PS If I understand what you are suggesting this would mean
extending the gimple-ssa-sprintf pass to the memxxx and strxxx
functions and running the pass later, after VRP.

  reply	other threads:[~2016-11-23 20:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-09  0:09 Martin Sebor
2016-11-16 17:33 ` PING " Martin Sebor
2016-11-22  0:02   ` PING 2 " Martin Sebor
2016-11-22 17:00 ` Jeff Law
2016-11-23 18:26   ` Martin Sebor
2016-11-23 19:10     ` Jeff Law
2016-11-23 19:32       ` Martin Sebor
2016-11-23 19:48         ` Jeff Law
2016-11-23 20:09           ` Martin Sebor [this message]
2016-11-23 20:31             ` Jeff Law
2016-11-23 21:39               ` Martin Sebor
2016-11-30  3:23                 ` Martin Sebor
2016-12-02 21:02                   ` Jeff Law
2016-12-02 21:19                   ` Jeff Law

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=c81b61ce-1ce7-c33a-7153-36d9274887f1@gmail.com \
    --to=msebor@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@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).