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

Re: Solaris cloning woes partly diagnosed

From
Linus Torvalds <torvalds@osdl.org>
Date
Apr 2, 2006, 19:18 UTC
Message-ID
<Pine.LNX.4.64.0604021159110.3050@g5.osdl.org>
In-Reply-To
<Pine.LNX.4.64.0604021118210.3050@g5.osdl.org>
On Sun, 2 Apr 2006, Linus Torvalds wrote:
> 
> Suddenly, some system calls will either return -1/EINTR, or they'll return 
> partial reads or writes. 

Hmm. If I read the IRC logs right, the bad pack is still a _valid_ pack, and passes git-verify-pack with flying colors.

That certainly implies that we had no problems with write-out: not only must the SHA1 of the resulting file match itself, but it must match the index too, and the number of objects there must match the index.

So the only way I see the pack being bad (if it does indeed pass git-verify-pack) is if the object list we generated was bad.

However, "-q" only affects git-pack-file itself, not the generation of the list. Which would imply that we have trouble _reading_ the list as it comes in through a pipe. Which is just insane, because we use just a bog-standard "fgets(... stdin)" for that. And no _way_ can stdio have problems with a few SIGALRM's, that would break a lot of other problems.

But Oeje1 seems to be saying (in http://pastebin.com/635566):
	git rev-list --objects --all | git pack-objects pack
	Generating pack...
	Done counting 15 objects.
	Deltifying 15 objects.
	 100% (15/15) done
	Writing 15 objects.
	 100% (15/15) done
	806439fdfa5e9990b03f9301bd68e243795fff50
where the result _should_ be 16385 objects, not 15.
And the thing is, the _only_ thing we do there is that
	while (fgets(line, sizeof(line), stdin) != NULL) {
		...
		add_object_entry(sha1, name_hash(NULL, line+41), 0);

so it really really looks like fgets() would have problems with a SIGALRM coming in and doesn't just re-try on EINTR. Can Solaris stdio _really_ be that broken? (Yeah, yeah, it may be "conforming". It's also so incredibly programmer-unfriendly that it's not even funny)

That would be truly insane. Can somebody with Solaris check what the following patch results in...

		Linus
----
diff --git a/pack-objects.c b/pack-objects.c
index ccfaa5f..daba5de 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -1099,8 +1099,18 @@ int main(int argc, char **argv)
 		fprintf(stderr, "Generating pack...\n");
 	}
 
-	while (fgets(line, sizeof(line), stdin) != NULL) {
+	for (;;) {
 		unsigned char sha1[20];
+
+		if (!fgets(line, sizeof(line), stdin)) {
+			if (feof(stdin))
+				break;
+			if (!ferror(stdin))
+				die("fgets returned NULL, not EOF, not error!");
+			if (errno == EINTR)
+				continue;
+			die("fgets: %s", strerror(errno));
+		}
 
 		if (line[0] == '-') {
 			if (get_sha1_hex(line+1, sha1))
Previous: Linus TorvaldsNext: Jason Riedy
Message 5 of 20 in “Solaris cloning woes partly diagnosed”
  1. Junio C HamanoApr 2, 2006
  2. Linus TorvaldsApr 2, 2006
  3. Jason RiedyApr 2, 2006
  4. Linus TorvaldsApr 2, 2006
  5. Linus TorvaldsApr 2, 2006
  6. Jason RiedyApr 2, 2006
  7. Linus TorvaldsApr 2, 2006
  8. 2/2 pack-objects: be incredibly anal about stdio semanticsLinus Torvalds, Apr 2, 2006
  9. Junio C HamanoApr 2, 2006
  10. Linus TorvaldsApr 2, 2006
  11. Jason RiedyApr 2, 2006
  12. Linus TorvaldsApr 2, 2006
  13. Use sigaction and SA_RESTART in read-tree.c; add option in Makefile.Jason Riedy, Apr 2, 2006
  14. Linus TorvaldsApr 3, 2006
  15. Junio C HamanoApr 3, 2006
  16. Linus TorvaldsApr 3, 2006
  17. Linus TorvaldsApr 3, 2006
  18. H. Peter AnvinApr 4, 2006
  19. [RFH] Solaris cloning woes...Junio C Hamano, Apr 4, 2006
  20. Jason RiedyApr 4, 2006

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.