git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Jeff King <peff@peff.net>, "Miriam R." <mirucam@gmail.com>,
	git <git@vger.kernel.org>
Subject: Re: [Outreachy] Return value before or after free()?
Date: Tue, 7 Jan 2020 01:58:59 +0000	[thread overview]
Message-ID: <20200107015859.GJ6570@camp.crustytoothpaste.net> (raw)
In-Reply-To: <20200107010809.GH6570@camp.crustytoothpaste.net>

[-- Attachment #1: Type: text/plain, Size: 1395 bytes --]

On 2020-01-07 at 01:08:09, brian m. carlson wrote:
> Unfortunately, compilers have gotten much more aggressive about assuming
> that undefined behavior never occurs and rewriting code based on that.
> clang is not as bad about doing that, but GCC is very aggressive about
> it.  There are multiple instances where NULL pointer checks have been
> optimized out because the compiler exploited undefined behavior to
> assume a pointer was never NULL.
> 
> In this case, the only case in which we can safely assume that this
> behavior is acceptable is that r is NULL, in which case C11 tells us
> that "no action occurs" due to the free. So the compiler could just
> optimize this out to a "return 0".  Just because it doesn't now doesn't
> mean we can assume it won't in the future, so we do need to fix this.
> 
> I'll send a patch.

Oof, I just realized that you had tagged this with "[Outreachy]", which
means that you were probably planning on sending a patch to fix this,
and then I went and did it instead, so let me apologize for doing that.

I sent it because oftentimes we say "we should fix this thing" and then
never do it because nobody sends a patch, but in this case I should have
paid more attention and waited for you to respond and send one instead.

Again, sorry about that.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 868 bytes --]

  reply	other threads:[~2020-01-07  1:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-06 21:15 [Outreachy] Return value before or after free()? Miriam R.
2020-01-06 21:30 ` Jeff King
2020-01-06 22:47   ` Jonathan Nieder
2020-01-06 23:34   ` Andreas Schwab
2020-01-07  1:08   ` brian m. carlson
2020-01-07  1:58     ` brian m. carlson [this message]
2020-01-07 20:40       ` Miriam R.

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=20200107015859.GJ6570@camp.crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=git@vger.kernel.org \
    --cc=mirucam@gmail.com \
    --cc=peff@peff.net \
    /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 NNTP newsgroup(s).