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

Re: [PATCH] read-cache: fix mem-pool allocation for multi-threaded index loading

From
Elijah Newren <newren@gmail.com>
Date
Sep 4, 2020, 19:28 UTC
Message-ID
<CABPp-BGQA98SOr4-+8LKd-V=oqB98hoDGh+AsvOGHjsM2ko=iA@mail.gmail.com>
In-Reply-To
<dbccbf13-9ebb-2464-4325-cac4c7767f74@web.de>
On Fri, Sep 4, 2020 at 10:34 AM René Scharfe <l.s.r@web.de> wrote:
Show 6 quoted lines
>
> 44c7e1a7e0 (mem-pool: use more standard initialization and finalization,
> 2020-08-15) moved the allocation of the mem-pool structure to callers.
> It also added an allocation to load_cache_entries_threaded(), but for an
> unrelated mem-pool.  Fix that by allocating the correct one instead --
> the one that is initialized two lines later.
Whoops; that's a somewhat embarrassing mistake.  Thanks for fixing it up for me.
Reviewed-by: Elijah Newren <newren@gmail.com>
Show 25 quoted lines
>
> Reported-by: Sandor Bodo-Merle <sbodomerle@gmail.com>
> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
> "GIT_TEST_INDEX_THREADS=3 make test" passes with this patch, but fails a
> lot without it.
>
>  read-cache.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/read-cache.c b/read-cache.c
> index fa291cdbee..ecf6f68994 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -2101,7 +2101,7 @@ static unsigned long load_cache_entries_threaded(struct index_state *istate, con
>                 nr = 0;
>                 for (j = p->ieot_start; j < p->ieot_start + p->ieot_blocks; j++)
>                         nr += p->ieot->entries[j].nr;
> -               istate->ce_mem_pool = xmalloc(sizeof(*istate->ce_mem_pool));
> +               p->ce_mem_pool = xmalloc(sizeof(*istate->ce_mem_pool));
>                 if (istate->version == 4) {
>                         mem_pool_init(p->ce_mem_pool,
>                                 estimate_cache_size_from_compressed(nr));
> --
> 2.28.0
Previous: René Scharfe
Message 3 of 3 in “possible segfault wint index threading”
  1. Sandor Bodo-MerleSep 4, 2020
  2. read-cache: fix mem-pool allocation for multi-threaded index loadingRené Scharfe, Sep 4, 2020
  3. Elijah NewrenSep 4, 2020

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.