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:03 UTC
Message-ID
<20111218050322.GA1787@sigill.intra.peff.net>
In-Reply-To
<CAOgd6zFr5LorTK6X5o6NQE3L61KhaUZG9tX4LEB4_Na_YKPPpA@mail.gmail.com>
On Sat, Dec 17, 2011 at 07:13:53PM -0800, Ryan O'Hara wrote:
> On Git for Windows (MinGW), at least, this command causes git to crash:
> 
> git commit -a --no-message --dry-run

On Linux, too, using just "git commit --no-message" (whether there is something to commit or not). This fixes it for me.

-- >8 --
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.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/commit.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/builtin/commit.c b/builtin/commit.c
index d0f27f9..336faff 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -104,7 +104,7 @@
 static int use_editor = 1, include_status = 1;
 static int show_ignored_in_status;
 static const char *only_include_assumed;
-static struct strbuf message;
+static struct strbuf message = STRBUF_INIT;
 
 static int null_termination;
 static enum {
-- 
1.7.8.rc3.14.gd2470
Previous: Ryan O'HaraNext: Jeff King
Message 2 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.