From: Nicolas Pitre <nico@cam.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Junio C Hamano <gitster@pobox.com>,
Alex Riesen <raa.lkml@gmail.com>,
Robin Rosenberg <robin.rosenberg.lists@dewire.com>,
Michal Rokos <michal.rokos@gmail.com>, GIT <git@vger.kernel.org>
Subject: Re: index-pack died on pread
Date: Fri, 27 Jul 2007 09:38:44 -0400 (EDT) [thread overview]
Message-ID: <alpine.LFD.0.999.0707270913270.3484@xanadu.home> (raw)
In-Reply-To: <alpine.LFD.0.999.0707262231280.3442@woody.linux-foundation.org>
On Thu, 26 Jul 2007, Linus Torvalds wrote:
>
>
> On Thu, 26 Jul 2007, Junio C Hamano wrote:
> >
> > If you mean the offset associated with fd, we actually do.
>
> Ahh, for some reason I thought we didn't (probably because the user likely
> doesn't care at all), but right you are..
The (only) user in Git does care indeed. The sequence of events goes
like this:
- Receive pack from remote location, parsing objects along and writing
a copy to the local pack file, as well as computing the SHA1 of non
delta objects.
- When all objects are parsed, the received pack SHA1 is verified.
If SHA1 doesn't match due to corruption in received data then everything
stops here with a "pack is corrupted (SHA1 mismatch)" error.
- For each received deltas: resolve those deltas to compute their
object SHA1. This is where pread() is involved on the local pack
file. If pread() fails to return proper data then the data won't
inflate properly and everything stops here with a "serious inflate
inconsistency" error.
- [OPTIONAL] Complete a thin pack with missing base objects for deltas
that weren't resolved yet. This involves pread() again, but it
_also_ append data to the same local pack file in the process. In
this case it is important that pread() restores the file position
when it returns or the appended objects won't be written where they
should.
This is optional because a thin pack is not received all the time,
not on a clone for example.
- Write trailing SHA1 to the local pack before moving it to its final
location. This also relies on pread() restoring the file position on
the local pack file or the trailing pack SHA1 won't be written where
it should.
So if pread() doesn't properly restore the file position then local pack
corruption will occur and the pack will be unusable. If pread() doesn't
properly read the asked data then index-pack will die.
> It really isn't that complex a system call. So I'm surprised at bugs
> there, and that makes me worry that there is something in git that
> triggers this.
Well, we have usage cases for a real pread() as well as our own
emulation which work. And the emulated pread() works in all cases so
far, so...
Nicolas
prev parent reply other threads:[~2007-07-27 13:39 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-23 12:52 index-pack died on pread Michal Rokos
2007-07-23 15:32 ` Alex Riesen
2007-07-25 20:07 ` Michal Rokos
2007-07-25 20:48 ` Alex Riesen
2007-07-23 17:04 ` Linus Torvalds
2007-07-23 18:03 ` Nicolas Pitre
2007-07-25 23:15 ` Robin Rosenberg
2007-07-25 23:44 ` Linus Torvalds
2007-07-26 12:42 ` Alex Riesen
2007-07-26 16:13 ` Linus Torvalds
2007-07-26 16:51 ` Alex Riesen
2007-07-26 18:02 ` Linus Torvalds
2007-07-27 3:43 ` Junio C Hamano
2007-07-27 5:36 ` Linus Torvalds
2007-07-27 9:50 ` Tomash Brechko
2007-07-27 10:33 ` Tomash Brechko
2007-07-27 13:38 ` Nicolas Pitre [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=alpine.LFD.0.999.0707270913270.3484@xanadu.home \
--to=nico@cam.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=michal.rokos@gmail.com \
--cc=raa.lkml@gmail.com \
--cc=robin.rosenberg.lists@dewire.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.
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).