All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Stefan Frühwirth" <stefan.fruehwirth@uni-graz.at>
To: <git@vger.kernel.org>
Subject: malloc memory corruption on merge-tree with leading newline
Date: Mon, 15 Feb 2016 22:39:39 +0100	[thread overview]
Message-ID: <56C2459B.5060805@uni-graz.at> (raw)

Hi,

in one specific circumstance, git-merge-tree exits with a segfault 
caused by "*** Error in `git': malloc(): memory corruption (fast)":

There has to be at least one commit first (as far as I can tell it 
doesn't matter what content). Then create a tree containing a file with 
a leading newline character (\n) followed by some random string, and 
another tree with a file containing a string without leading newline. 
Now merge trees: Segmentation fault.

There is a test case[1] kindly provided by chrisrossi, which he crafted 
after I discovered the problem[2] in the context of Pylons/acidfs.

Best,
Stefan

[1] https://gist.github.com/chrisrossi/f09c8bed70b364f9f12e
[2] https://github.com/Pylons/acidfs/issues/3

For in-line reference, here's the test case:

git init bug
cd bug
echo b > a
git add a
git commit -m "first commit"
echo > b
echo -n a >> b
git add b
git commit -m "second commit, first branch"
git checkout HEAD~1
git checkout -b other
echo -n a > b
git add b
git commit -m "second commit, second branch"
git merge-tree HEAD~1 master other
cd ..
rm -rf bug

             reply	other threads:[~2016-02-15 21:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-15 21:39 Stefan Frühwirth [this message]
2016-02-15 21:54 ` malloc memory corruption on merge-tree with leading newline Stefan Frühwirth
2016-02-16  1:12 ` [PATCH] merge_blobs: use strbuf instead of manually-sized mmfile_t Jeff King
2016-02-16  5:09   ` Eric Sunshine
2016-02-16  5:50     ` Jeff King
2016-02-16 12:14       ` Stefan Frühwirth
2016-02-16 20:35         ` Jeff King
2016-02-19 12:43           ` Stefan Frühwirth
2016-02-16 21:27       ` Junio C Hamano
2016-02-19 12:48         ` Stefan Frühwirth

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=56C2459B.5060805@uni-graz.at \
    --to=stefan.fruehwirth@uni-graz.at \
    --cc=git@vger.kernel.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.