Message ID | cover.1730901926.git.ps@pks.im (mailing list archive) |
---|---|
State | New |
Headers | show |
On Wed, Nov 06, 2024 at 04:10:14PM +0100, Patrick Steinhardt wrote: > Hi, > > this is the last part of my series of memory leak fixes. This series > goes a bit further than past series: > > - Patches 1 to 16 plug remaining memory leaks exposed by our test > suite. > > - Patches 17 to 21 remove the last remaining `UNLEAK()` annotations > and ultimately remove the macro itself. > > - Patch 22 works around a bug in the leak sanitizer itself. > > - Patches 23 and 24 drop annotations where leak-free tests pass with > the leak sanitizer. > > - Patches 25 and 26 unconditionally enable leak checking in all newly > added tests and then drop the `TEST_PASSES_SANITIZE_LEAK` > annotation. Hi Patrick. Thanks for working on this. It's been a while since 956d2e4639 (tests: add a test mode for SANITIZE=leak, run it in CI, 2021-09-23). This series marks certainly another milestone. I have left a few comments, none of them important. The series looks good to me. Just in case you re-roll, while reading the series I spotted some nits: diff --git a/bisect.c b/bisect.c index 518be70aa3..0e804086cb 100644 --- a/bisect.c +++ b/bisect.c @@ -641,7 +641,7 @@ static struct commit_list *skip_away(struct commit_list *list, int count) else if (previous) result = previous; else - result = list; + result = list; break; } previous = cur; diff --git a/builtin/init-db.c b/builtin/init-db.c index 9e069e2742..096f96b9c4 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -248,9 +248,9 @@ int cmd_init_db(int argc, } flags |= INIT_DB_EXIST_OK; - ret = init_db(git_dir, real_git_dir, template_dir, hash_algo, - ref_storage_format, initial_branch, - init_shared_repository, flags); + ret = init_db(git_dir, real_git_dir, template_dir, hash_algo, + ref_storage_format, initial_branch, + init_shared_repository, flags); free(template_dir_to_free); free(real_git_dir_to_free); > > So once this series lands, the expectation is that any newly added test > needs to be leak free by default. We still have an escape hatch in the > form of the SANITIZE_LEAK prerequisite, but patch authors are expected > to provide good arguments why their test cannot be made leak free. > > This series is built on top of 8f8d6eee53 (The seventh batch, > 2024-11-01) with ps/leakfixes-part-9 at c810549be1 > (list-objects-filter-options: work around reported leak on error, > 2024-11-05) merged into it. > > The series has some trivial conflicts with the removed test annotations > when merging with `seen`. There are two topics in-flight that introduce > new memory leaks (ds/path-walk and cc/promisor-remote-capability), both > of which are fixed by the below patch. I've sent a message in response > to the individual commits that introduce the leaks. > > Thanks! > > Patrick
On Sun, Nov 10, 2024 at 10:48:53PM +0100, Rubén Justo wrote: > On Wed, Nov 06, 2024 at 04:10:14PM +0100, Patrick Steinhardt wrote: > > Hi, > > > > this is the last part of my series of memory leak fixes. This series > > goes a bit further than past series: > > > > - Patches 1 to 16 plug remaining memory leaks exposed by our test > > suite. > > > > - Patches 17 to 21 remove the last remaining `UNLEAK()` annotations > > and ultimately remove the macro itself. > > > > - Patch 22 works around a bug in the leak sanitizer itself. > > > > - Patches 23 and 24 drop annotations where leak-free tests pass with > > the leak sanitizer. > > > > - Patches 25 and 26 unconditionally enable leak checking in all newly > > added tests and then drop the `TEST_PASSES_SANITIZE_LEAK` > > annotation. > > Hi Patrick. > > Thanks for working on this. > > It's been a while since 956d2e4639 (tests: add a test mode for SANITIZE=leak, > run it in CI, 2021-09-23). This series marks certainly another milestone. > > I have left a few comments, none of them important. The series looks > good to me. Just in case you re-roll, while reading the series I > spotted some nits: Thanks for your review, I've addressed your comments and will send out v2 soonish! patrick
diff --git a/promisor-remote.c b/promisor-remote.c index 06507b2ee1..0a4f7f1188 100644 --- a/promisor-remote.c +++ b/promisor-remote.c @@ -424,12 +424,12 @@ static void filter_promisor_remote(struct repository *repo, const char *info) { struct strbuf **remotes; - char *accept_str; + const char *accept_str; enum accept_promisor accept = ACCEPT_NONE; struct strvec names = STRVEC_INIT; struct strvec urls = STRVEC_INIT; - if (!git_config_get_string("promisor.acceptfromserver", &accept_str)) { + if (!git_config_get_string_tmp("promisor.acceptfromserver", &accept_str)) { if (!accept_str || !*accept_str || !strcasecmp("None", accept_str)) accept = ACCEPT_NONE; else if (!strcasecmp("KnownUrl", accept_str)) @@ -486,7 +486,6 @@ static void filter_promisor_remote(struct repository *repo, free(decoded_url); } - free(accept_str); strvec_clear(&names); strvec_clear(&urls); strbuf_list_free(remotes); diff --git a/t/helper/test-path-walk.c b/t/helper/test-path-walk.c index 06b103d876..fa3bfe46b5 100644 --- a/t/helper/test-path-walk.c +++ b/t/helper/test-path-walk.c @@ -85,7 +85,6 @@ int cmd__path_walk(int argc, const char **argv) OPT_END(), }; - initialize_repository(the_repository); setup_git_directory(); revs.repo = the_repository; @@ -110,5 +109,6 @@ int cmd__path_walk(int argc, const char **argv) "tags:%" PRIuMAX "\n", data.commit_nr, data.tree_nr, data.blob_nr, data.tag_nr); + release_revisions(&revs); return res; }