From: Roman Zippel <zippel@linux-m68k.org>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: Re: problem in unpack-trees.c
Date: Mon, 4 Dec 2006 12:36:04 +0100 (CET) [thread overview]
Message-ID: <Pine.LNX.4.64.0612041214590.1867@scrub.home> (raw)
In-Reply-To: <7vodqkq956.fsf@assigned-by-dhcp.cox.net>
Hi,
On Mon, 4 Dec 2006, Junio C Hamano wrote:
> Roman Zippel <zippel@linux-m68k.org> writes:
>
> > I looked into it and the problem is during the "git-read-tree --reset"
> > step and it seems that the local df_conflict_entry variable of
> > unpack_trees() survives past that function. If you check in
> > add_cache_entry() it's called with this variable and only because
> > verify_path() fails it's not added to the tree on the other archs, but on
> > m68k the data on the stack is a bit different and thus verify_path()
> > succeeds and the stack variable is added to the tree and later saved.
>
> I am very puzzled about this.
>
> You are correct that the address of the df_conflict_entry is
> assigned to "struct unpack_trees_options *o" in unpack_trees(),
> and add_cache_entry() are called from many places in the call
> chain that starts from that function. And these call sites do
> rely on the conflict_entry to have a NUL name to prevent
> add_cache_entry from adding the entry to the index. Which feels
> like a hack, but it should get the job done while it is running.
Ok, I see, I wasn't sure that this part was really intentional.
> On my x86-64 box with gcc 4 (i.e. "#define FLEX_ARRAY /* empty */"
> is used,
>
> #include "cache.h"
>
> int
> main(int ac, char **av)
> {
> printf("sz %zu\n", sizeof(struct cache_entry));
> printf("of %zu\n", offsetof(struct cache_entry, name));
> memset(&dfc, 0, sizeof(dfc));
> }
>
> size of "struct cache_entry" is 64 while the offset of name
> member is 62, so I am luckily getting two bytes of room for
> memset to fill and cause name[] to be properly NUL terminated.
> If the alignment requirement of the platform is smaller, we may
> be overstepping the struct when we access its name[] member.
Yes, on m68k both values are the same and thus name is not initialized.
Your patch should do the trick, I'll give it a try.
prev parent reply other threads:[~2006-12-04 11:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-03 1:21 problem in unpack-trees.c Roman Zippel
2006-12-04 9:53 ` Junio C Hamano
2006-12-04 10:00 ` Junio C Hamano
2006-12-04 11:36 ` Roman Zippel [this message]
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=Pine.LNX.4.64.0612041214590.1867@scrub.home \
--to=zippel@linux-m68k.org \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/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).