public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
* [PATCH] send-pack: clean up extra_have oid array
@ 2025-06-27 22:09 Jacob Keller
  2025-06-30 14:31 ` Junio C Hamano
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Jacob Keller @ 2025-06-27 22:09 UTC (permalink / raw)
  To: git; +Cc: Jacob Keller

From: Jacob Keller <jacob.keller@gmail•com>

Commit c8009635785e ("fetch-pack, send-pack: clean up shallow oid
array", 2024-09-25) cleaned up the shallow oid array in cmd_send_pack,
but didn't clean up extra_have, which is still leaked at program exit.
I suspect the particular tests in t5539 don't trigger any additions to
the extra_have array, which explains why the tests can pass leak free
despite this gap.

Signed-off-by: Jacob Keller <jacob.keller@gmail•com>
---
I didn't check to see why the t5539 tests don't leak. This leak occured for
me in a day-to-day run with my local git build that happened to still have
sanitizers enabled:

=================================================================
==2930359==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 2160 byte(s) in 1 object(s) allocated from:
    #0 0x7f51af6e5e2b in realloc.part.0 (/lib64/libasan.so.8+0xe5e2b) (BuildId: 7f1aa7e2e600e8c9d54ce6e3d36f3d31bfe7949a)
    #1 0x0000010dfc26 in xrealloc ../wrapper.c:140
    #2 0x000000c5d231 in oid_array_append ../oid-array.c:9
    #3 0x00000096036a in process_ref ../connect.c:296
    #4 0x00000096036a in get_remote_heads ../connect.c:374
    #5 0x00000072f8fc in cmd_send_pack ../builtin/send-pack.c:290
    #6 0x0000007d74d4 in run_builtin ../git.c:480
    #7 0x0000007d74d4 in handle_builtin ../git.c:746
    #8 0x0000007dbeb5 in run_argv ../git.c:813
    #9 0x0000007dbeb5 in cmd_main ../git.c:953
    #10 0x000000441dbf in main ../common-main.c:9
    #11 0x7f51aec115f4 in __libc_start_call_main (/lib64/libc.so.6+0x35f4) (BuildId: 2b3c02fe7e4d3811767175b6f323692a10a4e116)
    #12 0x7f51aec116a7 in __libc_start_main@@GLIBC_2.34 (/lib64/libc.so.6+0x36a7) (BuildId: 2b3c02fe7e4d3811767175b6f323692a10a4e116)
    #13 0x0000004440b4 in _start (/home/jekeller/libexec/git-core/git+0x4440b4) (BuildId: 6cd37a01505f2d67a4e7d39fd9f813b683be0300)

SUMMARY: AddressSanitizer: 2160 byte(s) leaked in 1 allocation(s)
---
 builtin/send-pack.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/builtin/send-pack.c b/builtin/send-pack.c
index c6e0e9d05186..61486e378cab 100644
--- a/builtin/send-pack.c
+++ b/builtin/send-pack.c
@@ -343,6 +343,7 @@ int cmd_send_pack(int argc,
 	free_refs(remote_refs);
 	free_refs(local_refs);
 	refspec_clear(&rs);
+	oid_array_clear(&extra_have);
 	oid_array_clear(&shallow);
 	clear_cas_option(&cas);
 	return ret;

---
base-commit: 16bd9f20a403117f2e0d9bcda6c6e621d3763e77
change-id: 20250627-jk-fix-leak-send-pack-e4787600cf60

Best regards,
--  
Jacob Keller <jacob.keller@gmail•com>


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-07-03 16:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-27 22:09 [PATCH] send-pack: clean up extra_have oid array Jacob Keller
2025-06-30 14:31 ` Junio C Hamano
2025-06-30 22:14   ` Jacob Keller
2025-07-01 17:40 ` Junio C Hamano
2025-07-01 20:36   ` Jacob Keller
2025-07-01 21:12     ` Junio C Hamano
2025-07-03 15:40   ` Jeff King
2025-07-03 16:26     ` Jacob Keller
2025-07-03 15:38 ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox