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

Re: index-pack died on pread

From
TBTomash Brechko <tomash.brechko@gmail.com>
Date
Jul 27, 2007, 09:50 UTC
Message-ID
<20070727095013.GA5047@moonlight.home>
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
Previous: Linus TorvaldsNext: Tomash Brechko
Message 15 of 17 in “index-pack died on pread”
  1. Michal RokosJul 23, 2007
  2. Alex RiesenJul 23, 2007
  3. Michal RokosJul 25, 2007
  4. Alex RiesenJul 25, 2007
  5. Linus TorvaldsJul 23, 2007
  6. Nicolas PitreJul 23, 2007
  7. Robin RosenbergJul 25, 2007
  8. Linus TorvaldsJul 25, 2007
  9. Alex RiesenJul 26, 2007
  10. Linus TorvaldsJul 26, 2007
  11. Alex RiesenJul 26, 2007
  12. Linus TorvaldsJul 26, 2007
  13. Junio C HamanoJul 27, 2007
  14. Linus TorvaldsJul 27, 2007
  15. Tomash BrechkoJul 27, 2007
  16. Tomash BrechkoJul 27, 2007
  17. Nicolas PitreJul 27, 2007

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.