All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre Habouzit <madcoder@debian.org>
To: "Shawn O. Pearce" <spearce@spearce.org>
Cc: cpettitt <cpettitt@gmail.com>, Git Mailing List <git@vger.kernel.org>
Subject: [PATCH] Fix regression in fast-import.c due to strbufs.
Date: Fri, 26 Oct 2007 09:59:12 +0200	[thread overview]
Message-ID: <20071026075912.GA25365@artemis.corp> (raw)
In-Reply-To: <20071026065301.GL14735@spearce.org>

[-- Attachment #1: Type: text/plain, Size: 2219 bytes --]

Without this strbuf_release, it yields a double free later, the command is
in fact stashed, and this is not a memory leak.

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---

  On Fri, Oct 26, 2007 at 06:53:01AM +0000, Shawn O. Pearce wrote:
  > cpettitt <cpettitt@gmail.com> wrote:
  > > I'm seeing the following errors when I run git-fast-import (on Intel
  > > OSX) with some data from a git-p4 import:
  > ....
  > > I believe these errors started showing up in commit
  > > b449f4cfc972929b638b90d375b8960c37790618. I did a bisect on
  > > fast-import.c and this was the first commit for that file that
  > > exhibits this bug with the input.
  > > 
  > > I thought I would check with the list to see if this is a known issue
  > > before I spend time trying to dig into it.
  > 
  > It is a known issue.  Someone else has reported the same thing,
  > and bisecting pointed at the same commit.  But they weren't able
  > to supply their input data for debugging by Pierre or myself as it
  > was a private project and they haven't had a chance to attempt to
  > debug it on their own.
  > 
  > Any light you can shed on the problem would be most appreciated.

  Wait, I believe I found the problem thanks to the "free" that fails.

  Could you please try that patch ? looking at the diff again, and
  knowing the issue is with an rc->buf (which are old command_buf
  stashed buffers) it looks like I migrated cmd_data improperly.

-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org
 fast-import.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/fast-import.c b/fast-import.c
index 6f888f6..f93d7d6 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1616,6 +1616,7 @@ static void cmd_data(struct strbuf *sb)
 		char *term = xstrdup(command_buf.buf + 5 + 2);
 		size_t term_len = command_buf.len - 5 - 2;
 
+		strbuf_detach(&command_buf, NULL);
 		for (;;) {
 			if (strbuf_getline(&command_buf, stdin, '\n') == EOF)
 				die("EOF in data (terminator '%s' not found)", term);
-- 
1.5.3.4.1358.gfae55-dirty


[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2007-10-26  7:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <de47e4420710251726nb45a19fk15b3105b735a74f8@mail.gmail.com>
2007-10-26  0:29 ` git-fast-import segfaults cpettitt
2007-10-26  6:53   ` Shawn O. Pearce
2007-10-26  7:59     ` Pierre Habouzit [this message]
2007-10-26 16:39       ` [PATCH] Fix regression in fast-import.c due to strbufs cpettitt
2007-10-26 17:25       ` Pierre Habouzit
2007-10-29  2:59         ` Shun Kei Leung
2007-10-29  6:29           ` Pierre Habouzit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071026075912.GA25365@artemis.corp \
    --to=madcoder@debian.org \
    --cc=cpettitt@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.