git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [Outreachy] Return value before or after free()?

From
Miriam R. <mirucam@gmail.com>
Date
Jan 7, 2020, 20:40 UTC
Message-ID
<CAN7CjDAZCxEmkvkqOw++VvBwF54cn_S1J+Uem61aNvjA7F3AiQ@mail.gmail.com>
In-Reply-To
<20200107015859.GJ6570@camp.crustytoothpaste.net>

El mar., 7 ene. 2020 a las 2:59, brian m. carlson (<sandals@crustytoothpaste.net>) escribió:

Show 21 quoted lines
>
> 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.
>
Sorry for my late reply, but I have been traveling all day.

Don't worry Brian, I am working on finishing bisect-helper conversion from shell to C. I am planning to send a patch related with this function as part of a patch series. My patch only changes the static header to be used in bisect related files. My mentor (Christian Couder) detected this and suggested me to ask the community.

> 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.
>

Don't worry again, next time if my question is related to a patch I am going to send I will actively write it and this way there will be no confusion. :)

> Again, sorry about that.
> --
> brian m. carlson: Houston, Texas, US
> OpenPGP: https://keybase.io/bk2204
Previous: brian m. carlson
Message 7 of 7 in “[Outreachy] Return value before or after free()?”
  1. Miriam R.Jan 6, 2020
  2. Jeff KingJan 6, 2020
  3. Jonathan NiederJan 6, 2020
  4. Andreas SchwabJan 6, 2020
  5. brian m. carlsonJan 7, 2020
  6. brian m. carlsonJan 7, 2020
  7. Miriam R.Jan 7, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.