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

Re: BUG: Git command causes crash

From
Jeff King <peff@peff.net>
Date
Dec 18, 2011, 05:07 UTC
Message-ID
<20111218050728.GB1787@sigill.intra.peff.net>
In-Reply-To
<20111218050322.GA1787@sigill.intra.peff.net>
On Sun, Dec 18, 2011 at 12:03:22AM -0500, Jeff King wrote:
Show 8 quoted lines
> Subject: [PATCH] commit: initialize static strbuf
> 
> Strbufs cannot rely on static all-zero initialization;
> instead, they must use STRBUF_INIT to point to the
> "slopbuf".
> 
> Without this patch, "git commit --no-message" segfaults
> reliably.
This one, too:
diff --git a/builtin/merge.c b/builtin/merge.c
index 2457940..28a3a7e 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -50,7 +50,7 @@ struct strategy {
 static int fast_forward_only, option_edit;
 static int allow_trivial = 1, have_message;
 static int overwrite_ignore = 1;
-static struct strbuf merge_msg;
+static struct strbuf merge_msg = STRBUF_INIT;
 static struct commit_list *remoteheads;
 static struct strategy **use_strategies;
 static size_t use_strategies_nr, use_strategies_alloc;

I'm not sure if you can actually trigger a segfault, but it clearly
violates the strbuf API.

-Peff
Previous: Jeff KingNext: Jeff King
Message 3 of 4 in “BUG: Git command causes crash”
  1. Ryan O'HaraDec 18, 2011
  2. Jeff KingDec 18, 2011
  3. Jeff KingDec 18, 2011
  4. Jeff KingDec 18, 2011

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.