git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* malloc memory corruption on merge-tree with leading newline
@ 2016-02-15 21:39 Stefan Frühwirth
  2016-02-15 21:54 ` Stefan Frühwirth
  2016-02-16  1:12 ` [PATCH] merge_blobs: use strbuf instead of manually-sized mmfile_t Jeff King
  0 siblings, 2 replies; 10+ messages in thread
From: Stefan Frühwirth @ 2016-02-15 21:39 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-02-19 12:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-15 21:39 malloc memory corruption on merge-tree with leading newline Stefan Frühwirth
2016-02-15 21:54 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).