git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tomash Brechko <tomash.brechko@gmail.com>
To: GIT <git@vger.kernel.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 13:50:13 +0400	[thread overview]
Message-ID: <20070727095013.GA5047@moonlight.home> (raw)
In-Reply-To: <alpine.LFD.0.999.0707262231280.3442@woody.linux-foundation.org>

Maybe this may help:

I compiled Git under Linux with NO_PREAD=1, and also _disabled_
file position save/restore in git_pread().  Now (I clone small repo to
save traffic):

  moonlight:/tmp$ git-clone git://people.freedesktop.org/~keithp/parsecvs
  Initialized empty Git repository in /tmp/parsecvs/.git/
  remote: Generating pack...
  remote: Done counting 476 objects.
  remote: Deltifying 476 objects.
  remote:  100% (476/476) done
  Indexing 476 objects...
  remote: Total 476 (delta 339), reused 0 (delta 0)
   100% (476/476) done
  Resolving 339 deltas...
   100% (339/339) done
  error: packfile /tmp/parsecvs/.git/objects/pack/pack-dda2f32249fab26059a035bd273dce9feaf6bade.pack does not match index
  error: packfile /tmp/parsecvs/.git/objects/pack/pack-dda2f32249fab26059a035bd273dce9feaf6bade.pack cannot be accessed
  error: packfile /tmp/parsecvs/.git/objects/pack/pack-dda2f32249fab26059a035bd273dce9feaf6bade.pack does not match index
  error: packfile /tmp/parsecvs/.git/objects/pack/pack-dda2f32249fab26059a035bd273dce9feaf6bade.pack cannot be accessed
  fatal: failed to unpack tree object HEAD

Errors are different, but seems Git is sensitive to pread() that messes
file position.  The problem may be in index-pack.c:

	static const char *open_pack_file(const char *pack_name)
	{
		if (from_stdin) {
	                ...
			pack_fd = output_fd;
		} else {
	                ...
			pack_fd = input_fd;
		}
	        ...
	}

There's no dup() call, so when we mess pack_fd (that is used in
pread() only), we also mess one more file descriptor that is used
sequentially (output_fd in my case), and so may corrupt the pack.


-- 
   Tomash Brechko

  reply	other threads:[~2007-07-27  9:50 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 [this message]
2007-07-27 10:33                 ` Tomash Brechko
2007-07-27 13:38               ` Nicolas Pitre

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=20070727095013.GA5047@moonlight.home \
    --to=tomash.brechko@gmail.com \
    --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 \
    /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).