git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Ben Lynn" <benlynn@gmail.com>
To: "Linus Torvalds" <torvalds@linux-foundation.org>
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Daniel Barkalow" <barkalow@iabervon.org>,
	"Git Mailing List" <git@vger.kernel.org>
Subject: Re: git bugs
Date: Wed, 11 Jun 2008 06:18:49 +0000	[thread overview]
Message-ID: <832adb090806102318k5727bb06p6c3211a6aebbfbe9@mail.gmail.com> (raw)
In-Reply-To: <832adb090806102258v3fd63605p8c45513690b78fe8@mail.gmail.com>

And I'm sure you've also realized we could use the old race fix with
SIZE_MAX instead of zero, i.e:

 if (!ce_match_stat_basic(ce, &st)) {
   ce->ce_size = ~0;
 }
 return; // don't bother with ce_modified_check_fs

This is dissatisfying in that we're abusing the size variable. I'd
much prefer adding a flag per entry. And now there are other file
sizes, albeit ridiculously large ones, that will trick git. But it is
much faster than examining file contents. Luckily the decision of
which fix to use is not up to me.

-Ben

On Wed, Jun 11, 2008 at 5:58 AM, Ben Lynn <benlynn@gmail.com> wrote:
> Am I going crazy? All of a sudden I think I can get away without a
> size zero hack. How about this smudging routine:
>
> if (!ce_match_stat_basic(ce, &st)) {
>  recompute_sha1_and_update_index();  // no other checks required
> }
>
> That should be sufficient. I think what happened was the following.
> Once upon a time, the race fix was "if (stats_match) cached_size = 0",
> which is nice because you don't have to examine file contents. Later,
> because of the
>
>  $ echo xyzzy >frotz ; git-update-index --add frotz ; : >frotz
>  $ sleep 3
>  $ echo filfre >nitfol ; git-update-index --add nitfol
>
> issue, the ce_modified_check_fs was added.
>
> But then if we're going to be examining file contents anyway, we may
> as well drop the whole size zero trick and simply update the hash. The
> bug I brought up also goes away.
>
> -Ben
>
> P.S: I could go through the history to see, but I bet there was a
> stage after the race condition was discovered but before it was
> realized that
>  $ git update-index 'foo'
>  : modify 'foo' in-place without changing its size
>  : wait for enough time
>  $ git update-index 'bar'
> was a problem.
>
> On Tue, Jun 10, 2008 at 7:39 PM, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
>>
>>
>> On Tue, 10 Jun 2008, Ben Lynn wrote:
>>>
>>> Ah, I hadn't seen that. Yes, it is better to use the first write as
>>> the timestamp. Would this catch everything? If the filesystem clock is
>>> monotonically increasing and consistent then with this setup, you can
>>> touch files even as they are being indexed? (Disregarding nonsense
>>> like changing sizes by 2^32.)
>>
>> Yes, I think that at that point it would protect against arbitrary
>> modifications even concurrently to index file creation.
>>
>> That said, I don't think you even need a new index file format. We could
>> just do a stat() on starting the index file creation, and then do a
>> futimes() system call at the end to re-set the mtime to the beginning
>> before we rename it back over the old index file.
>>
>>                Linus
>>
>

  reply	other threads:[~2008-06-11  6:19 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-10  8:41 git bugs Ben Lynn
2008-06-10 16:58 ` Daniel Barkalow
2008-06-10 17:44 ` Linus Torvalds
2008-06-10 18:45   ` Ben Lynn
2008-06-10 20:06     ` Linus Torvalds
2008-06-10 23:09       ` Ben Lynn
2008-06-10 23:38         ` Junio C Hamano
2008-06-11  0:02           ` Ben Lynn
2008-06-11  0:20             ` Junio C Hamano
2008-06-11  0:24               ` Ben Lynn
2008-06-11  0:53                 ` Ben Lynn
2008-06-11 12:46                 ` Stephen R. van den Berg
2008-06-12  6:51                   ` Ben Lynn
2008-06-11  1:36             ` Linus Torvalds
2008-06-11  2:04               ` Ben Lynn
2008-06-11  2:12                 ` Linus Torvalds
2008-06-11  2:31                   ` Ben Lynn
2008-06-11  2:39                     ` Linus Torvalds
2008-06-11  5:58                       ` Ben Lynn
2008-06-11  6:18                         ` Ben Lynn [this message]
2008-06-11 14:54                           ` Linus Torvalds
2008-06-11 17:52                             ` Ben Lynn
2008-06-11 18:10                               ` Linus Torvalds
2008-06-11 18:48                                 ` Ben Lynn
2008-06-11 18:53                                   ` Linus Torvalds
2008-06-11 20:57                                     ` Ben Lynn
2008-06-11 21:50                                     ` Junio C Hamano
2008-06-11 14:52                         ` Linus Torvalds
2008-06-12 20:06   ` Junio C Hamano
2008-06-13 10:10   ` Jeff King
2008-06-13 23:09     ` Junio C Hamano
2008-06-14  6:25       ` Jeff King
2008-06-12  3:17 ` Shawn O. Pearce
2008-06-12  6:46   ` Ben Lynn
2008-06-12  7:12   ` Johannes Schindelin
  -- strict thread matches above, loose matches on Subject: below --
2017-02-23 20:27 Sean Hunt
2017-02-24 16:52 ` Johannes Schindelin

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=832adb090806102318k5727bb06p6c3211a6aebbfbe9@mail.gmail.com \
    --to=benlynn@gmail.com \
    --cc=barkalow@iabervon.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=torvalds@linux-foundation.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).