Subject: [PATCH 00/22] Memory leak fixes (pt.6)

From: Patrick Steinhardt <[email-masked]>
Date: Mon, 26 Aug 2024 09:21:31 +0200

Hi,

here's another round of memory leak fixes. This is the second-last round
of "general" leak fixes -- so once this and the next series are merged,
I have made a full pass over all failing test suites. There will still
be a bunch of memory leaks, namely ~86 failing test suites.

I have documented a bunch of remaining leaks at [1]. Most of them are a
bit more involved to fix, so they will likely require separate series.
These issues relate to:

  - Simplifying commit history causes us to rewrite their parents, but
    we don't free the old parents in some cases. Hit e.g. by t6012.

  - The describe atom infrastructure as used by git-for-each-ref(1) is
    leaky. Hit e.g. by t6300, t6302.

  - Breaking rewrites causes memory leaks. Hit e.g. by t7524.

  - Cloning repositories causes us to re-initialize `the_repository`.
    This surfaces lifetime management issues with the `struct remote`
    that we use, which reuses storage held by `the_repository`. Hit e.g.
    by t5558.

  - The GPG interface is leaky. Hit e.g. by t7510, t7528.

If you want to do some puzzling, please feel free to pick up any of
these leaks :) I won't start working on them before I have the final
part of memory leak fixes merged.

This patch series builds on top of 6a09c36371 (The eighth batch,
2024-08-23) with Junio's ps/leakfixes-part-5 at 13b23d2da5 (transport:
fix leaking negotiation tips, 2024-08-22) merged into it.

Patrick

[1]: https://gitlab.com/groups/gitlab-org/-/epics/14943

Patrick Steinhardt (22):
  t/test-lib: allow skipping leak checks for passing tests
  fetch-pack: fix memory leaks on fetch negotiation
  send-pack: fix leaking common object IDs
  builtin/push: fix leaking refspec query result
  upload-pack: fix leaking child process data on reachability checks
  submodule: fix leaking fetch task data
  builtin/submodule--helper: fix leaking refs on push-check
  remote: fix leaking tracking refs
  remote: fix leak in reachability check of a remote-tracking ref
  send-pack: fix leaking push cert nonce
  gpg-interface: fix misdesigned signing key interfaces
  object: clear grafts when clearing parsed object pool
  shallow: free grafts when unregistering them
  shallow: fix leaking members of `struct shallow_info`
  negotiator/skipping: fix leaking commit entries
  builtin/repack: fix leaking line buffer when packing promisors
  builtin/pack-objects: plug leaking list of keep-packs
  builtin/grep: fix leaking object context
  builtin/fmt-merge-msg: fix leaking buffers
  match-trees: fix leaking prefixes in `shift_tree()`
  merge-ort: fix two leaks when handling directory rename modifications
  builtin/repack: fix leaking keep-pack list

 builtin/fmt-merge-msg.c              |  2 ++
 builtin/grep.c                       |  1 +
 builtin/pack-objects.c               |  1 +
 builtin/push.c                       |  8 +++--
 builtin/repack.c                     |  3 ++
 builtin/submodule--helper.c          |  2 ++
 builtin/tag.c                        |  3 +-
 commit.c                             | 23 ++++--------
 commit.h                             |  3 +-
 fetch-pack.c                         |  3 ++
 gpg-interface.c                      | 26 ++++++++------
 gpg-interface.h                      |  4 +--
 match-trees.c                        | 10 ++++--
 merge-ort.c                          |  4 ++-
 negotiator/skipping.c                |  7 ++--
 object.c                             | 14 +++++++-
 object.h                             |  4 ++-
 remote.c                             |  6 +++-
 repository.c                         |  2 +-
 send-pack.c                          | 52 ++++++++++++++++++----------
 shallow.c                            | 15 ++++++--
 submodule.c                          |  2 ++
 t/t5516-fetch-push.sh                |  1 +
 t/t5526-fetch-submodules.sh          |  1 +
 t/t5531-deep-submodule-push.sh       |  1 +
 t/t5533-push-cas.sh                  |  1 +
 t/t5534-push-signed.sh               |  1 +
 t/t5537-fetch-shallow.sh             |  1 +
 t/t5538-push-shallow.sh              |  1 +
 t/t5549-fetch-push-http.sh           |  1 +
 t/t5552-skipping-fetch-negotiator.sh |  2 ++
 t/t5616-partial-clone.sh             |  1 +
 t/t6132-pathspec-exclude.sh          |  1 +
 t/t6135-pathspec-with-attrs.sh       |  2 ++
 t/t6200-fmt-merge-msg.sh             |  1 +
 t/t6409-merge-subtree.sh             |  1 +
 t/t6423-merge-rename-directories.sh  |  1 +
 t/t6500-gc.sh                        |  1 +
 t/t7703-repack-geometric.sh          |  1 +
 t/test-lib.sh                        | 11 +++++-
 upload-pack.c                        | 22 ++++++++----
 41 files changed, 175 insertions(+), 72 deletions(-)

-- 
2.46.0.164.g477ce5ccd6.dirty