This repository has been archived by the owner on Sep 1, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: EdenFS uses libgit2 with multiple threads. This is supported by libgit2, but `git_libgit2_shutdown` does not clean up per-thread data it allocates. This results in memory leaks. I discovered this leak while writing D13113450: StartWithRepoTestGit.test_eden_start_mounts_checkouts fails because LSAN reports the following leak from EdenFS: ``` Direct leak of 104 byte(s) in 1 object(s) allocated from: #0 0x555f6f in calloc (.../buck-out/dev/gen/eden/fs/service/edenfs+0x555f6f) #1 0x7f15d1fd1728 in git__calloc .../libgit2-0.27.5/src/util.h:99:14 #2 0x7f15d1fd1b10 in git__global_state .../libgit2-0.27.5/src/global.c:330:8 #3 0x7f15d1fc8b44 in giterr_set .../libgit2-0.27.5/src/errors.c:59:18 #4 0x7f15d1ff9bad in git_odb__error_notfound .../libgit2-0.27.5/src/odb.c:1539:3 #5 0x7f15d1ffd579 in pack_entry_find .../libgit2-0.27.5/src/odb_pack.c:271:9 #6 0x7f15d1ffda32 in pack_backend__read .../libgit2-0.27.5/src/odb_pack.c:400:15 #7 0x7f15d1ff8911 in odb_read_1 .../libgit2-0.27.5/src/odb.c:1054:12 #8 0x7f15d1ff8b19 in git_odb_read .../libgit2-0.27.5/src/odb.c:1105:10 #9 0x7f15d1ff54a2 in git_object_lookup_prefix .../libgit2-0.27.5/src/object.c:169:12 #10 0x7f15d1ff5570 in git_object_lookup .../libgit2-0.27.5/src/object.c:200:9 #11 0x7f15d1ff5fff in git_tree_lookup .../libgit2-0.27.5/src/object_api.c:56:9 #12 0x7f15c43a822a in facebook::eden::GitBackingStore::getTreeImpl(facebook::eden::Hash const&) eden/fs/store/git/GitBackingStore.cpp:88 #13 0x7f15c43d4daa in facebook::eden::GitBackingStore::getTreeForCommit(facebook::eden::Hash const&)::$_8::operator()(std::unique_ptr<facebook::eden::Tree, std::default_delete<facebook::eden::Tree> >) const eden/fs/store/git/GitBackingStore.cpp:186 ``` libgit2 has no API to clean up these allocations. (Note: `giterr_clear` does not free the thread-local error string buffer.). Aside from making EdenFS use libgit2 from one thread or fixing libgit2, we can't do anything about the leaks. As a workaround, suppress leak reports for allocations from the problematic libgit2 APIs. Reviewed By: simpkins Differential Revision: D13163830 fbshipit-source-id: b33e1ca07541442665dab2718aabe9919c44d8b9
- Loading branch information