git/list[1] front-page[2] threads[3] people[4] search[5] about
wed 2026-10-07 18:06 UTC

Re: [PATCH v9] show-branch: convert per-branch flags to commit-slab

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 21, 2026, 18:51 UTC
Message-ID
<xmqqzezkw4zq.fsf@gitster.g>
In-Reply-To
<20260717224435.74504-1-gatlavishweshwarreddy26@gmail.com>
Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com> writes:
> I took time to read through the code carefully before sending this.

Hmph. I hate to say this, but I am finding it difficult to trust your "carefully" at this point.

    $ make
    $ ./git show-branch master next
    Floating point exception (core dumped).

While I have not spent the time to exhaustively find all bugs in this code [*], it is disturbing that the simplest use of the command immediately crashes. The reason for this crash is trivial.

Show 10 quoted lines
>  static struct commit_name_slab name_slab;
>  
> +define_commit_slab(commit_rev_flags, uint64_t);
> +static struct commit_rev_flags rev_flags_slab;
> +static int flags_stride; /* number of uint64_t words per commit */
> +
>  static struct commit_name *commit_to_name(struct commit *commit)
>  {
>  	return *commit_name_slab_at(&name_slab, commit);
>  }

The code still uses name_slab to associate names with commits, and commit_to_name() is called by functions like name_commits(), which is used in cmd_show_branch(). Yet, the patch does this:

Show 6 quoted lines
> @@ -713,8 +773,6 @@ int cmd_show_branch(int ac,
>  	const char **args_copy = NULL;
>  	int ret;
>  
> -	init_commit_name_slab(&name_slab);
> -

The code simply discards the initialization for that slab, leaving name_slab BSS-initialized. Consequently, all members in the struct are initialized to 0, including the '.slab_size' member.

This init_commit_name_slab() call is not moved elsewhere; it simply disappeared without an explanation.

When commit_to_name() tries to look up a commit in the slab, it first attempts to determine which slab should contain the data for the commit, using this code from <commit-slab-impl.h>:

scope elemtype *slabname## _at_peek(struct slabname *s,			\
						  const struct commit *c, \
						  int add_if_missing)   \
{									\
	unsigned int nth_slab, nth_slot;				\
									\
	nth_slab = c->index / s->slab_size;				\
	nth_slot = c->index % s->slab_size;				\
									\
And we all know what would happen when you divide by zero.
[Footnote]
 * ... and I will not.
 
Previous: Gatla Vishweshwar ReddyNext: Gatla Vishweshwar Reddy
Message 23 of 27 in “show-branch: convert object.flags usage to a commit-slab”
  1. show-branch: convert object.flags usage to a commit-slabGatla Vishweshwar Reddy, Jul 14, 2026
  2. show-branch: convert object.flags to commit-slab with uint64_tGatla Vishweshwar Reddy, Jul 14, 2026
  3. Junio C HamanoJul 14, 2026
  4. Jeff KingJul 14, 2026
  5. show-branch: convert per-branch flags to commit-slabGatla Vishweshwar Reddy, Jul 15, 2026
  6. Junio C HamanoJul 15, 2026
  7. show-branch: convert per-branch flags to commit-slabGatla Vishweshwar Reddy, Jul 15, 2026
  8. Patrick SteinhardtJul 15, 2026
  9. Junio C HamanoJul 15, 2026
  10. show-branch: convert per-branch flags to commit-slabGatla Vishweshwar Reddy, Jul 15, 2026
  11. Junio C HamanoJul 15, 2026
  12. show-branch: convert per-branch flags to commit-slabGatla Vishweshwar Reddy, Jul 15, 2026
  13. Junio C HamanoJul 17, 2026
  14. show-branch: convert per-branch flags to commit-slabGatla Vishweshwar Reddy, Jul 17, 2026
  15. Patrick SteinhardtJul 17, 2026
  16. Patrick SteinhardtJul 17, 2026
  17. Gatla Vishweshwar ReddyJul 17, 2026
  18. Patrick SteinhardtJul 17, 2026
  19. Junio C HamanoJul 17, 2026
  20. show-branch: convert per-branch flags to commit-slabGatla Vishweshwar Reddy, Jul 17, 2026
  21. Junio C HamanoJul 17, 2026
  22. show-branch: convert per-branch flags to commit-slabGatla Vishweshwar Reddy, Jul 17, 2026
  23. Junio C HamanoJul 21, 2026
  24. show-branch: convert per-branch flags to commit-slabGatla Vishweshwar Reddy, Jul 21, 2026
  25. Junio C HamanoJul 23, 2026
  26. Gatla Vishweshwar ReddyJul 23, 2026
  27. Gatla Vishweshwar ReddyJul 24, 2026

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.