git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org, "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: Re: LSan curiosity in t1300
Date: Thu, 08 Sep 2022 11:03:05 -0700	[thread overview]
Message-ID: <xmqq8rmtrbfq.fsf@gitster.g> (raw)
In-Reply-To: <Yxl91jfycCo7O7Pp@coredump.intra.peff.net> (Jeff King's message of "Thu, 8 Sep 2022 01:29:58 -0400")

Jeff King <peff@peff.net> writes:

> And it is complaining that we've leaked "key". But as you can see, we
> always free it. The problem is that for this particular invocation we
> die("missing environment variable name"), so of course we don't make it
> to the free(). Normally this is OK, though. The "key" variable is still
> on the stack, so the leak-checker should realize that it's still
> reachable.
>
> But if you run this in a debugger, you'll find that under -O2 the "key"
> variable has been optimized out! So LSan is producing the wrong result
> due to the optimization. It doesn't know that "key" is conceptually
> still reachable.

Yikes.  

Is that related to the cause of the other patch from you, i.e.
wanting to get "registers" but unable to?  If they manage to get the
value of the register that holds 'key', would this disappear, I
wonder?

> Maybe this is a known problem, but it was certainly surprising to me.
> I'm not sure if we should do anything about it or not. It doesn't seem
> to trigger in CI, even though I don't see us taking any steps there to
> use -O0 or similar. So we can perhaps ignore it for now, and this
> message can serve as a warning. But if we think LSan isn't reliable
> under higher optimizations, we could perhaps teach the Makefile to
> prefer -O0 when it sees SANITIZE=leak.

Nice note to leave here, I agree.


  parent reply	other threads:[~2022-09-08 18:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-08  5:29 LSan curiosity in t1300 Jeff King
2022-09-08 15:42 ` [PATCH] tests: opt "git --config-env" test out of SANITIZE=leak Ævar Arnfjörð Bjarmason
2022-09-08 18:40   ` Jeff King
2022-09-23  8:28     ` Ævar Arnfjörð Bjarmason
2022-09-23 21:01       ` Jeff King
2022-09-26  8:56         ` Ævar Arnfjörð Bjarmason
2022-09-08 18:03 ` Junio C Hamano [this message]
2022-09-08 18:15   ` LSan curiosity in t1300 Jeff King

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=xmqq8rmtrbfq.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --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).