We noticed some problems when trying out the string-based config backend. The following roughly illustrates the issue:
Reproduction steps
Building libgit2 with:
cmake -DUSE_GSSAPI=OFF -DUSE_HTTPS=OFF -DBUILD_SHARED_LIBS=OFF -DUSE_NTLMCLIENT=OFF ..
cmake --build . --parallel 12
Then writing a file called demo.c:
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "git2.h"
#include "git2/sys/config.h"
int main(void)
{
git_libgit2_init();
git_config *cfg = NULL;
git_config_backend *backend = NULL;
const char *contents = "[commit]\ngpgsign=true\n";
/* Step 1: create an empty config and add an in-memory backend */
int err = git_config_new(&cfg);
assert(err == 0);
err = git_config_backend_from_string(&backend, contents, strlen(contents), NULL);
assert(err == 0);
err = git_config_add_backend(cfg, backend, GIT_CONFIG_LEVEL_LOCAL, NULL, 0);
assert(err == 0);
/* Step 2: read a value — internally calls config_memory_get and then
* git_config_entry_free, which (before the fix) drops config_list
* refcount to 0 and frees it */
int value = 0;
err = git_config_get_bool(&value, cfg, "commit.gpgsign");
assert(err == 0);
printf("commit.gpgsign = %s\n", value ? "true" : "false");
/* Step 3: free the config — calls config_memory_free which (before the
* fix) calls git_config_list_free on the already-freed config_list */
git_config_free(cfg);
printf("exiting\n");
git_libgit2_shutdown();
return 0;
}
Building this with:
cc -g -o demo demo.c -lgit2 -L. -I../include -lz
and then running under valgrind produces the following output:
Details
==12163== Memcheck, a memory error detector
==12163== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==12163== Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyright info
==12163== Command: ./demo
==12163==
commit.gpgsign = true
==12163== Invalid read of size 4
==12163== at 0x11552D: git_atomic32_dec (thread.h:136)
==12163== by 0x1175F7: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a97aa0 is 0 bytes inside a block of size 104 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x1175B5: config_list_free (config_list.c:149)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x1171D9: git_config_list_new (config_list.c:46)
==12163== by 0x1183EB: config_backend_new (config_mem.c:295)
==12163== by 0x1185A0: git_config_backend_from_string (config_mem.c:340)
==12163== by 0x10E1E4: main (demo.c:21)
==12163==
==12163== Invalid read of size 8
==12163== at 0x117605: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a97aa8 is 8 bytes inside a block of size 104 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x1175B5: config_list_free (config_list.c:149)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x1171D9: git_config_list_new (config_list.c:46)
==12163== by 0x1183EB: config_backend_new (config_mem.c:295)
==12163== by 0x1185A0: git_config_backend_from_string (config_mem.c:340)
==12163== by 0x10E1E4: main (demo.c:21)
==12163==
==12163== Invalid read of size 4
==12163== at 0x1163B4: git_config_list_pathmap_iterate (config_list.c:28)
==12163== by 0x1174E5: config_list_free (config_list.c:128)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a97ab0 is 16 bytes inside a block of size 104 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x1175B5: config_list_free (config_list.c:149)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x1171D9: git_config_list_new (config_list.c:46)
==12163== by 0x1183EB: config_backend_new (config_mem.c:295)
==12163== by 0x1185A0: git_config_backend_from_string (config_mem.c:340)
==12163== by 0x10E1E4: main (demo.c:21)
==12163==
==12163== Invalid read of size 8
==12163== at 0x116141: git_config_list_pathmap_dispose (config_list.c:28)
==12163== by 0x1174F9: config_list_free (config_list.c:131)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a97ac0 is 32 bytes inside a block of size 104 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x1175B5: config_list_free (config_list.c:149)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x1171D9: git_config_list_new (config_list.c:46)
==12163== by 0x1183EB: config_backend_new (config_mem.c:295)
==12163== by 0x1185A0: git_config_backend_from_string (config_mem.c:340)
==12163== by 0x10E1E4: main (demo.c:21)
==12163==
==12163== Invalid read of size 8
==12163== at 0x116151: git_config_list_pathmap_dispose (config_list.c:28)
==12163== by 0x1174F9: config_list_free (config_list.c:131)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a97ac8 is 40 bytes inside a block of size 104 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x1175B5: config_list_free (config_list.c:149)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x1171D9: git_config_list_new (config_list.c:46)
==12163== by 0x1183EB: config_backend_new (config_mem.c:295)
==12163== by 0x1185A0: git_config_backend_from_string (config_mem.c:340)
==12163== by 0x10E1E4: main (demo.c:21)
==12163==
==12163== Invalid read of size 8
==12163== at 0x116161: git_config_list_pathmap_dispose (config_list.c:28)
==12163== by 0x1174F9: config_list_free (config_list.c:131)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a97ad0 is 48 bytes inside a block of size 104 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x1175B5: config_list_free (config_list.c:149)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x1171D9: git_config_list_new (config_list.c:46)
==12163== by 0x1183EB: config_backend_new (config_mem.c:295)
==12163== by 0x1185A0: git_config_backend_from_string (config_mem.c:340)
==12163== by 0x10E1E4: main (demo.c:21)
==12163==
==12163== Invalid write of size 8
==12163== at 0x4852CCC: memset (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x116182: git_config_list_pathmap_dispose (config_list.c:28)
==12163== by 0x1174F9: config_list_free (config_list.c:131)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a97ab0 is 16 bytes inside a block of size 104 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x1175B5: config_list_free (config_list.c:149)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x1171D9: git_config_list_new (config_list.c:46)
==12163== by 0x1183EB: config_backend_new (config_mem.c:295)
==12163== by 0x1185A0: git_config_backend_from_string (config_mem.c:340)
==12163== by 0x10E1E4: main (demo.c:21)
==12163==
==12163== Invalid write of size 8
==12163== at 0x4852CD3: memset (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x116182: git_config_list_pathmap_dispose (config_list.c:28)
==12163== by 0x1174F9: config_list_free (config_list.c:131)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a97ac0 is 32 bytes inside a block of size 104 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x1175B5: config_list_free (config_list.c:149)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x1171D9: git_config_list_new (config_list.c:46)
==12163== by 0x1183EB: config_backend_new (config_mem.c:295)
==12163== by 0x1185A0: git_config_backend_from_string (config_mem.c:340)
==12163== by 0x10E1E4: main (demo.c:21)
==12163==
==12163== Invalid write of size 8
==12163== at 0x4852CF6: memset (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x116182: git_config_list_pathmap_dispose (config_list.c:28)
==12163== by 0x1174F9: config_list_free (config_list.c:131)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a97ad0 is 48 bytes inside a block of size 104 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x1175B5: config_list_free (config_list.c:149)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x1171D9: git_config_list_new (config_list.c:46)
==12163== by 0x1183EB: config_backend_new (config_mem.c:295)
==12163== by 0x1185A0: git_config_backend_from_string (config_mem.c:340)
==12163== by 0x10E1E4: main (demo.c:21)
==12163==
==12163== Invalid read of size 4
==12163== at 0x1171AA: git_config_list_headmap_iterate (config_list.c:29)
==12163== by 0x11753D: config_list_free (config_list.c:134)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a97ad8 is 56 bytes inside a block of size 104 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x1175B5: config_list_free (config_list.c:149)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x1171D9: git_config_list_new (config_list.c:46)
==12163== by 0x1183EB: config_backend_new (config_mem.c:295)
==12163== by 0x1185A0: git_config_backend_from_string (config_mem.c:340)
==12163== by 0x10E1E4: main (demo.c:21)
==12163==
==12163== Invalid read of size 8
==12163== at 0x116F37: git_config_list_headmap_dispose (config_list.c:29)
==12163== by 0x117551: config_list_free (config_list.c:138)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a97ae8 is 72 bytes inside a block of size 104 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x1175B5: config_list_free (config_list.c:149)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x1171D9: git_config_list_new (config_list.c:46)
==12163== by 0x1183EB: config_backend_new (config_mem.c:295)
==12163== by 0x1185A0: git_config_backend_from_string (config_mem.c:340)
==12163== by 0x10E1E4: main (demo.c:21)
==12163==
==12163== Invalid read of size 8
==12163== at 0x116F47: git_config_list_headmap_dispose (config_list.c:29)
==12163== by 0x117551: config_list_free (config_list.c:138)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a97af0 is 80 bytes inside a block of size 104 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x1175B5: config_list_free (config_list.c:149)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x1171D9: git_config_list_new (config_list.c:46)
==12163== by 0x1183EB: config_backend_new (config_mem.c:295)
==12163== by 0x1185A0: git_config_backend_from_string (config_mem.c:340)
==12163== by 0x10E1E4: main (demo.c:21)
==12163==
==12163== Invalid read of size 8
==12163== at 0x116F57: git_config_list_headmap_dispose (config_list.c:29)
==12163== by 0x117551: config_list_free (config_list.c:138)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a97af8 is 88 bytes inside a block of size 104 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x1175B5: config_list_free (config_list.c:149)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x1171D9: git_config_list_new (config_list.c:46)
==12163== by 0x1183EB: config_backend_new (config_mem.c:295)
==12163== by 0x1185A0: git_config_backend_from_string (config_mem.c:340)
==12163== by 0x10E1E4: main (demo.c:21)
==12163==
==12163== Invalid write of size 8
==12163== at 0x4852CCC: memset (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x116F78: git_config_list_headmap_dispose (config_list.c:29)
==12163== by 0x117551: config_list_free (config_list.c:138)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a97ad8 is 56 bytes inside a block of size 104 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x1175B5: config_list_free (config_list.c:149)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x1171D9: git_config_list_new (config_list.c:46)
==12163== by 0x1183EB: config_backend_new (config_mem.c:295)
==12163== by 0x1185A0: git_config_backend_from_string (config_mem.c:340)
==12163== by 0x10E1E4: main (demo.c:21)
==12163==
==12163== Invalid write of size 8
==12163== at 0x4852CD3: memset (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x116F78: git_config_list_headmap_dispose (config_list.c:29)
==12163== by 0x117551: config_list_free (config_list.c:138)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a97ae8 is 72 bytes inside a block of size 104 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x1175B5: config_list_free (config_list.c:149)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x1171D9: git_config_list_new (config_list.c:46)
==12163== by 0x1183EB: config_backend_new (config_mem.c:295)
==12163== by 0x1185A0: git_config_backend_from_string (config_mem.c:340)
==12163== by 0x10E1E4: main (demo.c:21)
==12163==
==12163== Invalid write of size 8
==12163== at 0x4852CF6: memset (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x116F78: git_config_list_headmap_dispose (config_list.c:29)
==12163== by 0x117551: config_list_free (config_list.c:138)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a97af8 is 88 bytes inside a block of size 104 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x1175B5: config_list_free (config_list.c:149)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x1171D9: git_config_list_new (config_list.c:46)
==12163== by 0x1183EB: config_backend_new (config_mem.c:295)
==12163== by 0x1185A0: git_config_backend_from_string (config_mem.c:340)
==12163== by 0x10E1E4: main (demo.c:21)
==12163==
==12163== Invalid read of size 8
==12163== at 0x117556: config_list_free (config_list.c:140)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a97b00 is 96 bytes inside a block of size 104 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x1175B5: config_list_free (config_list.c:149)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x1171D9: git_config_list_new (config_list.c:46)
==12163== by 0x1183EB: config_backend_new (config_mem.c:295)
==12163== by 0x1185A0: git_config_backend_from_string (config_mem.c:340)
==12163== by 0x10E1E4: main (demo.c:21)
==12163==
==12163== Invalid read of size 8
==12163== at 0x117564: config_list_free (config_list.c:142)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a981c0 is 0 bytes inside a block of size 24 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x11759A: config_list_free (config_list.c:145)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x1176E1: git_config_list_append (config_list.c:180)
==12163== by 0x117CC2: read_variable_cb (config_mem.c:89)
==12163== by 0x119A9A: git_config_parse (config_parse.c:564)
==12163== by 0x117E07: parse_config (config_mem.c:116)
==12163== by 0x1180A7: config_memory_open (config_mem.c:183)
==12163== by 0x10F0D8: git_config_add_backend (config.c:377)
==12163== by 0x10E235: main (demo.c:24)
==12163==
==12163== Invalid read of size 8
==12163== at 0x11756F: config_list_free (config_list.c:143)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a981d0 is 16 bytes inside a block of size 24 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x11759A: config_list_free (config_list.c:145)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x1176E1: git_config_list_append (config_list.c:180)
==12163== by 0x117CC2: read_variable_cb (config_mem.c:89)
==12163== by 0x119A9A: git_config_parse (config_parse.c:564)
==12163== by 0x117E07: parse_config (config_mem.c:116)
==12163== by 0x1180A7: config_memory_open (config_mem.c:183)
==12163== by 0x10F0D8: git_config_add_backend (config.c:377)
==12163== by 0x10E235: main (demo.c:24)
==12163==
==12163== Invalid read of size 8
==12163== at 0x117573: config_list_free (config_list.c:143)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a97f98 is 8 bytes inside a block of size 56 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x11758E: config_list_free (config_list.c:144)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x117C0A: read_variable_cb (config_mem.c:78)
==12163== by 0x119A9A: git_config_parse (config_parse.c:564)
==12163== by 0x117E07: parse_config (config_mem.c:116)
==12163== by 0x1180A7: config_memory_open (config_mem.c:183)
==12163== by 0x10F0D8: git_config_add_backend (config.c:377)
==12163== by 0x10E235: main (demo.c:24)
==12163==
==12163== Invalid free() / delete / delete[] / realloc()
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x11757E: config_list_free (config_list.c:143)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a98010 is 0 bytes inside a block of size 5 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x11757E: config_list_free (config_list.c:143)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1739F8: git__strdup (alloc.c:55)
==12163== by 0x117C45: read_variable_cb (config_mem.c:81)
==12163== by 0x119A9A: git_config_parse (config_parse.c:564)
==12163== by 0x117E07: parse_config (config_mem.c:116)
==12163== by 0x1180A7: config_memory_open (config_mem.c:183)
==12163== by 0x10F0D8: git_config_add_backend (config.c:377)
==12163== by 0x10E235: main (demo.c:24)
==12163==
==12163== Invalid read of size 8
==12163== at 0x117583: config_list_free (config_list.c:144)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a981d0 is 16 bytes inside a block of size 24 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x11759A: config_list_free (config_list.c:145)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x1176E1: git_config_list_append (config_list.c:180)
==12163== by 0x117CC2: read_variable_cb (config_mem.c:89)
==12163== by 0x119A9A: git_config_parse (config_parse.c:564)
==12163== by 0x117E07: parse_config (config_mem.c:116)
==12163== by 0x1180A7: config_memory_open (config_mem.c:183)
==12163== by 0x10F0D8: git_config_add_backend (config.c:377)
==12163== by 0x10E235: main (demo.c:24)
==12163==
==12163== Invalid free() / delete / delete[] / realloc()
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x11758E: config_list_free (config_list.c:144)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a97f90 is 0 bytes inside a block of size 56 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x11758E: config_list_free (config_list.c:144)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x117C0A: read_variable_cb (config_mem.c:78)
==12163== by 0x119A9A: git_config_parse (config_parse.c:564)
==12163== by 0x117E07: parse_config (config_mem.c:116)
==12163== by 0x1180A7: config_memory_open (config_mem.c:183)
==12163== by 0x10F0D8: git_config_add_backend (config.c:377)
==12163== by 0x10E235: main (demo.c:24)
==12163==
==12163== Invalid free() / delete / delete[] / realloc()
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x11759A: config_list_free (config_list.c:145)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a981c0 is 0 bytes inside a block of size 24 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x11759A: config_list_free (config_list.c:145)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x1176E1: git_config_list_append (config_list.c:180)
==12163== by 0x117CC2: read_variable_cb (config_mem.c:89)
==12163== by 0x119A9A: git_config_parse (config_parse.c:564)
==12163== by 0x117E07: parse_config (config_mem.c:116)
==12163== by 0x1180A7: config_memory_open (config_mem.c:183)
==12163== by 0x10F0D8: git_config_add_backend (config.c:377)
==12163== by 0x10E235: main (demo.c:24)
==12163==
==12163== Invalid free() / delete / delete[] / realloc()
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x1175B5: config_list_free (config_list.c:149)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x118365: config_memory_free (config_mem.c:281)
==12163== by 0x10E5C2: backend_instance_free (config.c:67)
==12163== by 0x10E607: config_free (config.c:77)
==12163== by 0x10E6DE: git_config_free (config.c:91)
==12163== by 0x10E2F2: main (demo.c:37)
==12163== Address 0x4a97aa0 is 0 bytes inside a block of size 104 free'd
==12163== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C7D: stdalloc__free (stdalloc.c:28)
==12163== by 0x115550: git__free (alloc.h:39)
==12163== by 0x1175B5: config_list_free (config_list.c:149)
==12163== by 0x117619: git_config_list_free (config_list.c:155)
==12163== by 0x1179E6: git_config_list_entry_free (config_list.c:268)
==12163== by 0x10E590: git_config_entry_free (config.c:59)
==12163== by 0x110272: git_config_get_bool (config.c:901)
==12163== by 0x10E287: main (demo.c:31)
==12163== Block was alloc'd at
==12163== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==12163== by 0x173C21: stdalloc__malloc (stdalloc.c:15)
==12163== by 0x1737FF: git__malloc (alloc.h:19)
==12163== by 0x1738CF: git__calloc (alloc.c:31)
==12163== by 0x1171D9: git_config_list_new (config_list.c:46)
==12163== by 0x1183EB: config_backend_new (config_mem.c:295)
==12163== by 0x1185A0: git_config_backend_from_string (config_mem.c:340)
==12163== by 0x10E1E4: main (demo.c:21)
==12163==
exiting
==12163==
==12163== HEAP SUMMARY:
==12163== in use at exit: 0 bytes in 0 blocks
==12163== total heap usage: 49 allocs, 53 frees, 2,562 bytes allocated
==12163==
==12163== All heap blocks were freed -- no leaks are possible
==12163==
==12163== For lists of detected and suppressed errors, rerun with: -s
==12163== ERROR SUMMARY: 31 errors from 25 contexts (suppressed: 0 from 0)
Possible solution
I haven't really traced through the code to fully understand it, but something like the following may help:
diff --git a/src/libgit2/config_mem.c b/src/libgit2/config_mem.c
index 3c159073f..96e389af7 100644
--- a/src/libgit2/config_mem.c
+++ b/src/libgit2/config_mem.c
@@ -199,6 +199,7 @@ static int config_memory_get(git_config_backend *backend, const char *key, git_c
if ((error = git_config_list_get(&entry, memory_backend->config_list, key)) != 0)
return error;
+ git_config_list_incref(memory_backend->config_list);
*out = &entry->base;
return 0;
}
That at least seems to make valgrind run clean.
Version of libgit2 (release number or SHA1)
On current main of 86c7738.
We noticed some problems when trying out the string-based config backend. The following roughly illustrates the issue:
Reproduction steps
Building libgit2 with:
Then writing a file called
demo.c:Building this with:
and then running under valgrind produces the following output:
Details
Possible solution
I haven't really traced through the code to fully understand it, but something like the following may help:
That at least seems to make valgrind run clean.
Version of libgit2 (release number or SHA1)
On current main of 86c7738.