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

Re: [PATCH] Makefile: force -O0 when compiling with SANITIZE=leak

From
Jeff King <peff@peff.net>
Date
Oct 21, 2022, 06:04 UTC
Message-ID
<Y1I2Z9K4iaAr+GiP@coredump.intra.peff.net>
In-Reply-To
<939ccb0c-005c-4f98-a6ca-3f8e5cda1641@gmail.com>
On Thu, Oct 20, 2022 at 08:57:31PM +0200, Rubén Justo wrote:
> "-O2" is what goes public, testing it, directly or indirectly, is useful.
> Another thing is the pay-off..

Sort of. The leak-check build itself is not what goes public, so we have already diverged from a release build. But yes, if there were cases that -O2 caught that -O0 did not, that would be of interest.

But are there?

I.e., we already know of false positives with -O2. Are there false negatives with -O0?

The example you give below goes the other way:
Show 8 quoted lines
> "False positives" makes me think the leak checker does its best.  And the
> compiler.  This "-O0 leak" is ignored by both, with "-O2":
> 
> 	void func()
> 	{
> 		malloc(1024);
> 		exit(1);
> 	}

It is a false negative with -O2. Which again seems to argue for using -O0.

> UNLEAK(), "-O0" as a /second opinion/ /confirmation/, some attention to the
> false positives,... are things that doesn't sound so bad.  Maybe there is a
> better way.  Dunno.

I don't know why we'd want to prefer -O2 if we know it produces worse results, but don't have any cases where it produce better ones (or even a plausible explanation for why it might). Sure, we could squelch its false positives with UNLEAK(), but:

  - that's per-site work, versus setting -O0 once
  - UNLEAK() suppresses false positives, but it also would suppress true
    positives (e.g., if the code later changed and somebody introduced a
    leak). It seems better to avoid that if possible.
-Peff
Previous: Rubén JustoNext: Junio C Hamano
Message 7 of 8 in “linux-leaks CI failure on master”
  1. Taylor BlauOct 18, 2022
  2. Jeff KingOct 18, 2022
  3. Makefile: force -O0 when compiling with SANITIZE=leakJeff King, Oct 18, 2022
  4. Ævar Arnfjörð BjarmasonOct 18, 2022
  5. Jeff KingOct 19, 2022
  6. Rubén JustoOct 20, 2022
  7. Jeff KingOct 21, 2022
  8. Junio C HamanoOct 19, 2022

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.