git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git bugs

From
Ben Lynn <benlynn@gmail.com>
Date
Jun 11, 2008, 06:18 UTC
Message-ID
<832adb090806102318k5727bb06p6c3211a6aebbfbe9@mail.gmail.com>
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:
Show 56 quoted lines
> 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
>>
>
Previous: Ben LynnNext: Linus Torvalds
Message 20 of 35 in “git bugs”
  1. Ben LynnJun 10, 2008
  2. Daniel BarkalowJun 10, 2008
  3. Linus TorvaldsJun 10, 2008
  4. Ben LynnJun 10, 2008
  5. Linus TorvaldsJun 10, 2008
  6. Ben LynnJun 10, 2008
  7. Junio C HamanoJun 10, 2008
  8. Ben LynnJun 11, 2008
  9. Junio C HamanoJun 11, 2008
  10. Ben LynnJun 11, 2008
  11. Ben LynnJun 11, 2008
  12. Stephen R. van den BergJun 11, 2008
  13. Ben LynnJun 12, 2008
  14. Linus TorvaldsJun 11, 2008
  15. Ben LynnJun 11, 2008
  16. Linus TorvaldsJun 11, 2008
  17. Ben LynnJun 11, 2008
  18. Linus TorvaldsJun 11, 2008
  19. Ben LynnJun 11, 2008
  20. Ben LynnJun 11, 2008
  21. Linus TorvaldsJun 11, 2008
  22. Ben LynnJun 11, 2008
  23. Linus TorvaldsJun 11, 2008
  24. Ben LynnJun 11, 2008
  25. Linus TorvaldsJun 11, 2008
  26. Ben LynnJun 11, 2008
  27. Junio C HamanoJun 11, 2008
  28. Linus TorvaldsJun 11, 2008
  29. Junio C HamanoJun 12, 2008
  30. Jeff KingJun 13, 2008
  31. Junio C HamanoJun 13, 2008
  32. Jeff KingJun 14, 2008
  33. Shawn O. PearceJun 12, 2008
  34. Ben LynnJun 12, 2008
  35. Johannes SchindelinJun 12, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.