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

[PATCH] send-pack: clean up extra_have oid array

From
Jacob Keller <jacob.e.keller@intel.com>
Date
Jun 27, 2025, 22:09 UTC
Message-ID
<20250627-jk-fix-leak-send-pack-v1-1-aadcf0ed8a4b@gmail.com>
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>
Next: Junio C Hamano
Message 1 of 9 in “send-pack: clean up extra_have oid array”
  1. send-pack: clean up extra_have oid arrayJacob Keller, Jun 27, 2025
  2. Junio C HamanoJun 30, 2025
  3. Jacob KellerJun 30, 2025
  4. Junio C HamanoJul 1, 2025
  5. Jacob KellerJul 1, 2025
  6. Junio C HamanoJul 1, 2025
  7. Jeff KingJul 3, 2025
  8. Jacob KellerJul 3, 2025
  9. Jeff KingJul 3, 2025

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.