public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: Martin Sebor <msebor@gmail.com>,
	Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>,
	gcc Patches <gcc-patches@gcc.gnu.org>,
	Richard Biener <rguenther@suse.de>
Subject: Re: PR80613
Date: Thu, 04 May 2017 19:03:00 -0000	[thread overview]
Message-ID: <b9fd09f4-5ff5-3727-30ab-caf938248452@redhat.com> (raw)
In-Reply-To: <aa84bce1-8bce-48bf-61dd-2276c8f74698@gmail.com>

On 05/04/2017 11:52 AM, Martin Sebor wrote:
> On 05/04/2017 10:00 AM, Prathamesh Kulkarni wrote:
>> Hi,
>> As mentioned in PR, the issue is that cddce1 marks the call to
>> __builtin_strdup as necessary:
>> marking necessary through .MEM_6 stmt p_7 = __builtin_strdup (&d);
>>
>> and since p_7 doesn't get added to worklist in propagate_necessity()
>> because it's used only within free(), it's treated as "dead"
>> and wrongly gets released.
>> The patch fixes that by adding strdup/strndup in corresponding condition
>> in eliminate_unnecessary_stmts().
>>
>> Another issue, was that my previous patch failed to remove multiple
>> calls to strdup:
>> char *f(char **tt)
>> {
>>   char *t = *tt;
>>   char *p;
>>
>>   p = __builtin_strdup (t);
>>   p = __builtin_strdup (t);
>>   return p;
> 
> Since this is clearly a bug in the program -- the first result
> leaks -- would it make sense to issue a warning before removing
> the duplicate call?  (It would be nice to issue a warning not
> just for strdup but also for other memory allocation functions,
> so perhaps that should be a separate enhancement request.)
Seems like it should be a separate enhancement request.

jeff

  parent reply	other threads:[~2017-05-04 18:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-04 16:03 PR80613 Prathamesh Kulkarni
2017-05-04 17:55 ` PR80613 Martin Sebor
2017-05-04 18:19   ` PR80613 Trevor Saunders
2017-05-04 19:03   ` Jeff Law [this message]
2017-05-04 19:06 ` PR80613 Jeff Law
2017-05-05  7:20   ` PR80613 Richard Biener
2017-05-05  9:16     ` PR80613 Prathamesh Kulkarni
2017-05-05 10:27       ` PR80613 Richard Biener

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=b9fd09f4-5ff5-3727-30ab-caf938248452@redhat.com \
    --to=law@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=msebor@gmail.com \
    --cc=prathamesh.kulkarni@linaro.org \
    --cc=rguenther@suse.de \
    /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).