Skip to content

reroll ma/plugleaks; more `object_array`-fixes

Martin Ågren git 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest6 patches 16 repliesIn review
  2. v11 patch 2 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6builtin/commit: fix memory leak in `prepare_index()`builtin/commit.c+10 -50 replies
2/6commit: fix memory leak in `reduce_heads()`commit.c+1 -00 replies
3/6leak_pending: use `object_array_clear()`, not `free()`bisect.c builtin/checkout.c bundle.c +1 more+29 -31 reply
4/6object_array: use `object_array_clear()`, not `free()`builtin/reflog.c diff-lib.c submodule.c +1 more+6 -72 replies
5/6object_array: add and use `object_array_pop()`builtin/fast-export.c builtin/fsck.c builtin/reflog.c +3 more+24 -103 replies
6/6pack-bitmap[-write]: use `object_array_clear()`, don't leakpack-bitmap-write.c pack-bitmap.c+4 -101 reply

Reviews trailers per patch

2 of 6 patches have a Reviewed-by or Acked-by.

PatchJeff King
1/6R-b
2/6R-b
3/6
4/6
5/6
6/6

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/6] reroll ma/plugleaks; more `object_array`-fixes
Quoted 8 lines · Jeff King
Quoted 5 lines · Martin Ågren

Instead of conditionally freeing rev.pending.objects, just call object_array_clear() on rev.pending. This means we don't poke as much into the implementation, which is already a good thing, but also that we free the individual entries as well, thereby fixing a memory-leak.

Quoted 8 lines

Looks good. A similar bug was the exact reason for adding the function in 46be82312. I did a grep for 'free.*\.objects' to see if there were other cases.

There are some hits. E.g., the one in orphaned_commit_warning(). It does something funny with setting revs.leak_pending. But I _think_ after the whole thing is done and we call free(refs.objects), that probably ought to be an object_array_clear().

Looking into this, I found various classes of leaks and oddities. I ended up replacing this patch with four patches.

Since Junio collected my "independent" patches into ma/leakplugs, this is a re-roll of that whole topic. I got the first two patches from Junio's tree. The only difference there is "builtin/" at the very start of the first commit message.

The third patch handles the places where we use leak_pending. The fourth addresses the rest of what your grep found and includes the original patch from this thread. While working on those, I felt that some callers fiddle a bit too much with the internals of object_array. One pattern leaks, another only looks like it. That resulted in the last two patches.

Since ma/plugleaks is branched off maint, I did the same with this series. It applies on master and next and has a minor conflict on pu (handle_commit() got a new argument).

Martin

Martin Ågren (6):
builtin/commit: fix memory leak in prepare_index()
commit: fix memory leak in reduce_heads()
leak_pending: use object_array_clear(), not free()
object_array: use object_array_clear(), not free()
object_array: add and use object_array_pop() pack-bitmap[-write]: use object_array_clear(), don't leak

 bisect.c              |  3 ++-
 builtin/checkout.c    |  9 ++++++++-
 builtin/commit.c      | 15 ++++++++++-----
 builtin/fast-export.c |  3 +--
 builtin/fsck.c        |  7 +------
 builtin/reflog.c      |  6 +++---
 bundle.c              |  9 ++++++++-
 commit.c              |  1 +
 diff-lib.c            |  3 +--
 object.c              | 13 +++++++++++++
 object.h              |  7 +++++++
 pack-bitmap-write.c   |  4 +---
 pack-bitmap.c         | 10 +++-------
 revision.h            | 11 +++++++++++
 shallow.c             |  2 +-
 submodule.c           |  4 ++--
 upload-pack.c         |  2 +-
 17 files changed, 74 insertions(+), 35 deletions(-)
Signature · 1 line
2.14.1.727.g9ddaf86