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

[PATCH] format-patch: mark rev_info with UNLEAK

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 16, 2021, 23:37 UTC
Message-ID
<xmqqpmpw6s0p.fsf_-_@gitster.g>
In-Reply-To
<xmqqee6dz5s9.fsf@gitster.g>

The comand uses a single instance of rev_info on stack, makes a single revision traversal and exit. Mark the resources held by the rev_info structure with UNLEAK().

We do not do this at lower level in revision.c or cmd_log_walk(), as a new caller of the revision traversal API can make unbounded number of rev_info during a single run, and UNLEAK() would not a be suitable mechanism to deal with such a caller.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
    Junio C Hamano <gitster@pobox.com> writes:
    > Jerry Zhang <jerry@skydio.com> writes:
    >
    >>  t/t4126-apply-empty.sh      | 22 ++++++++++++++++++----
    >>  4 files changed, 30 insertions(+), 7 deletions(-)
    >> ...
    >> diff --git a/t/t4126-apply-empty.sh b/t/t4126-apply-empty.sh
    >> index ceb6a79fe0..949e284d14 100755
    >> --- a/t/t4126-apply-empty.sh
    >> +++ b/t/t4126-apply-empty.sh
    >> @@ -7,10 +7,12 @@ test_description='apply empty'
    >>  test_expect_success setup '
    >>  	>empty &&
    >>  	git add empty &&
    >>  	test_tick &&
    >>  	git commit -m initial &&
    >> +	git commit --allow-empty -m "empty commit" &&
    >> +	git format-patch --always HEAD~ >empty.patch &&
    >>  	for i in a b c d e
    >
    > When merged with anything that has ab/mark-leak-free-tests-even-more
    > topic, this will start breaking the tests, as it is my understanding
    > that "git log" family hasn't been audited and converted for leak
    > sanitizer.
    > ...
    > I am tempted to drop the "TEST_PASSES" bit from this script for now,
    > but I have to say that the "mark leak-free tests" topic took us in
    > an awkward place.  We probably want to do something a bit more fine
    > grained about it.
    Luckily, this test script is small enough that format-patch is the
    only new offender, it seems, and with the attached patch I plan to
    queue on a separate topic merged, it seem it no longer upsets the
    sanitizer.
 builtin/log.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/builtin/log.c b/builtin/log.c
index f75d87e8d7..a7bca8353b 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -2241,6 +2241,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 	strbuf_release(&rdiff1);
 	strbuf_release(&rdiff2);
 	strbuf_release(&rdiff_title);
+	UNLEAK(rev);
 	return 0;
 }
 
-- 
2.34.1-472-g213ab46be7
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 8 of 13 in “git-apply: add --quiet flag”
  1. 1/2 git-apply: add --quiet flagJerry Zhang, Dec 13, 2021
  2. 2/2 git-apply: add --allow-empty flagJerry Zhang, Dec 13, 2021
  3. Junio C HamanoDec 16, 2021
  4. t4204 is not sanitizer clean at allJunio C Hamano, Dec 16, 2021
  5. Ævar Arnfjörð BjarmasonDec 17, 2021
  6. Junio C HamanoDec 17, 2021
  7. Ævar Arnfjörð BjarmasonDec 17, 2021
  8. format-patch: mark rev_info with UNLEAKJunio C Hamano, Dec 16, 2021
  9. Ævar Arnfjörð BjarmasonDec 17, 2021
  10. Junio C HamanoDec 17, 2021
  11. Junio C HamanoDec 17, 2021
  12. Ævar Arnfjörð BjarmasonDec 17, 2021
  13. Junio C HamanoDec 13, 2021

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.