From: Jeff King <peff@peff.net>
To: Bernhard Posselt <mail@bernhard-posselt.com>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: Memory corruption when rebasing with git version 1.8.1.5 on arch
Date: Tue, 19 Mar 2013 09:44:52 -0400 [thread overview]
Message-ID: <20130319134452.GA6752@sigill.intra.peff.net> (raw)
In-Reply-To: <51484125.9000307@bernhard-posselt.com>
On Tue, Mar 19, 2013 at 11:42:45AM +0100, Bernhard Posselt wrote:
> it seems that the memory corruption does not happen anymore when i change
>
> [apply]
> whitespace = fix
>
> to
>
> [apply]
> #whitespace = fix
>
> so fixing whitespaces may be the culprit
Thanks, I'm able to reproduce with the config you showed. The other key
element seems to be using tab-in-indent. I am not too familiar with
this code, but I was able to get a much smaller reproduction recipe:
-- >8 --
# make tabs more obvious by using "Q" instead
q_to_tab() {
perl -lpe 's/Q/\t/g'
}
q_to_tab >preimage <<\EOF
QQa
QQb
QQc
d
QQe
QQf
QQg
EOF
q_to_tab >patch <<\EOF
diff --git a/preimage b/preimage
--- a/preimage
+++ b/preimage
@@ -1,7 +1,6 @@ public static function store($filename) {
QQa
QQb
QQc
-QQd
QQe
QQf
QQg
EOF
valgrind \
git -c core.whitespace=tab-in-indent apply --whitespace=fix patch
-- 8< --
which yields:
==7112== Invalid write of size 2
==7112== at 0x4C2C023: memcpy (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7112== by 0x40C365: update_pre_post_images (apply.c:2165)
==7112== by 0x40CC52: match_fragment (apply.c:2402)
[...]
==7112== Address 0x6e57a5e is 0 bytes after a block of size 94 alloc'd
==7112== at 0x4C2A26B: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7112== by 0x4C2A51F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7112== by 0x535193: xrealloc (wrapper.c:100)
==7112== by 0x51C322: strbuf_grow (strbuf.c:74)
==7112== by 0x51C10C: strbuf_init (strbuf.c:34)
==7112== by 0x40D329: apply_one_fragment (apply.c:2602)
[...]
and so on. I haven't quite figured out what is going on. It looks like
we call update_pre_post_images with postlen==0, which causes it to just
write the fixed postimage into the existing buffer. But of course the
fixed version is bigger, because we are expanding the tabs into 8
spaces (but it _doesn't_ break if each line starts with only one tab,
which confuses me).
I'm not too familiar with this code. Maybe Junio can say more.
-Peff
next prev parent reply other threads:[~2013-03-19 13:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-08 12:19 Memory corruption when rebasing with git version 1.8.1.5 on arch Bernhard Posselt
2013-03-08 21:28 ` Jeff King
2013-03-09 0:08 ` Bernhard Posselt
2013-03-09 4:48 ` Jeff King
2013-03-09 10:54 ` Bernhard Posselt
2013-03-10 7:05 ` Jeff King
2013-03-10 11:04 ` Bernhard Posselt
2013-03-10 11:45 ` Bernhard Posselt
2013-03-11 5:18 ` Jeff King
2013-03-19 10:42 ` Bernhard Posselt
2013-03-19 13:44 ` Jeff King [this message]
2013-03-19 16:02 ` Junio C Hamano
2013-03-22 18:08 ` Junio C Hamano
2013-03-22 21:24 ` Jeff King
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=20130319134452.GA6752@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mail@bernhard-posselt.com \
/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 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).