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

Re: [PATCH 1/4] test-bloom: stop setting up Git directory twice

From
Jeff King <peff@peff.net>
Date
Nov 6, 2023, 17:20 UTC
Message-ID
<20231106172024.GA10414@coredump.intra.peff.net>
In-Reply-To
<fb1cc73ed3395ba3de72aba70d7679dd85ebb034.1699267422.git.ps@pks.im>
On Mon, Nov 06, 2023 at 11:45:53AM +0100, Patrick Steinhardt wrote:
Show 7 quoted lines
> We're setting up the Git directory twice in the `test-tool bloom`
> helper, once at the beginning of `cmd_bloom()` and once in the local
> subcommand implementation `get_bloom_filter_for_commit()`. This can lead
> to memory leaks as we'll overwrite variables of `the_repository` with
> newly allocated data structures. On top of that it's simply unnecessary.
> 
> Fix this by only setting up the Git directory once.

Makes sense. This situation was created by 094a685cd7 (t: make test-bloom initialize repository, 2020-07-29), which added the setup call at the start of the program.

That commit closed the door to running test-bloom outside of a repository for sub-commands that could handle it (perhaps the murmur3 one, but I didn't test). So there are two possible directions here:

  - drop the call in cmd__bloom() and make sure all of the relevant
    sub-command functions do the setup.
  - drop the one command-specific one (i.e., your patch)

In practice I don't think anybody cares about running this test-helper outside of a repository, and having to do setup in each sub-command is an extra maintenance burden. So I think your patch is the best direction.

-Peff
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 3 of 9 in “Memory leak fixes”
  1. 0/4 Memory leak fixesPatrick Steinhardt, Nov 6, 2023
  2. 1/4 test-bloom: stop setting up Git directory twicePatrick Steinhardt, Nov 6, 2023
  3. Jeff KingNov 6, 2023
  4. 2/4 shallow: fix memory leak when registering shallow rootsPatrick Steinhardt, Nov 6, 2023
  5. Jeff KingNov 6, 2023
  6. 3/4 setup: refactor `upgrade_repository_format()` to have common exitPatrick Steinhardt, Nov 6, 2023
  7. 4/4 setup: fix leaking repository formatPatrick Steinhardt, Nov 6, 2023
  8. Jeff KingNov 6, 2023
  9. Junio C HamanoNov 7, 2023

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.