memory leak when cloning a repository
- From
Jacob Keller <jacob.e.keller@intel.com>
- Date
- Mar 5, 2026, 20:51 UTC
- Message-ID
- <b9fa930e-7d5e-47f1-8896-1997cf7c0cdb@intel.com>
Hi,
I recently ran into a memory leak that appears consistently when I clone a repository:
================================================================= ==581989==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 27168 byte(s) in 1 object(s) allocated from:
#0 0x7f0e100e6f2b in malloc (/lib64/libasan.so.8+0xe6f2b) (BuildId: 25975f766867e9e604dc5a71a8befeaed3301942)
#1 0x00000122ab77 in git_mmap ../compat/mmap.c:15
#2 0x000001169466 in xmmap_gently ../wrapper.c:884
#3 0x00000116959b in xmmap ../wrapper.c:907
#4 0x000000d168fd in check_packed_git_idx ../packfile.c:179
#5 0x000000d16cce in open_pack_index ../packfile.c:282
#6 0x000000d25273 in find_pack_entry_one ../packfile.c:2078
#7 0x00000099f969 in check_connected ../connected.c:148
#8 0x0000004dabdb in update_remote_refs ../builtin/clone.c:550
#9 0x0000004dabdb in cmd_clone ../builtin/clone.c:1602
#10 0x00000080a9b4 in run_builtin ../git.c:506
#11 0x00000080a9b4 in handle_builtin ../git.c:780
#12 0x000000810727 in run_argv ../git.c:863
#13 0x000000810727 in cmd_main ../git.c:985
#14 0x000000449e6f in main ../common-main.c:9
#15 0x7f0e0f6105b4 in __libc_start_call_main (/lib64/libc.so.6+0x35b4) (BuildId: ff0267465bc3d76e21003b3bc5598fd5ee63e261)
#16 0x7f0e0f610667 in __libc_start_main@@GLIBC_2.34 (/lib64/libc.so.6+0x3667) (BuildId: ff0267465bc3d76e21003b3bc5598fd5ee63e261)
#17 0x00000044c264 in _start (/home/jekeller/libexec/git-core/git+0x44c264) (BuildId: f75e04052d9435ea15ebf4480b490fe2eb150d92)SUMMARY: AddressSanitizer: 27168 byte(s) leaked in 1 allocation(s).
I tried digging into why this leak occurs but so far I don't have a good idea.
This happens when running on next: 7842e34a6654 ("Sync with 'master'")Thanks, Jake