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

Re: [JGIT PATCH 10/10] BROKEN TEST: ObjectLoader stays valid across repacks

From
Robin Rosenberg <robin.rosenberg.lists@dewire.com>
Date
Apr 21, 2009, 23:16 UTC
Message-ID
<200904220116.51076.robin.rosenberg.lists@dewire.com>
In-Reply-To
<1240276872-17893-11-git-send-email-spearce@spearce.org>
tisdag 21 april 2009 03:21:12 skrev "Shawn O. Pearce" <spearce@spearce.org>:
Show 6 quoted lines
> This doesn't doesn't work.
> 
> What we are trying to verify is that an ObjectLoader remains valid
> if the underlying storage for the object has moved, such as when a
> repository is repacked, the old pack was deleted, and the object is
> now in the new pack.

So, I had an idea and started hacking and suddenly the supposedly ok cases started crashing like this.

org.spearce.jgit.errors.MissingObjectException: Missing unknown 4a75554761c96be80602c05145d1ef41c77e1b72
	at org.spearce.jgit.revwalk.RevWalk.parseAny(RevWalk.java:704)
	at org.spearce.jgit.lib.ConcurrentRepackTest.parse(ConcurrentRepackTest.java:189)
	at org.spearce.jgit.lib.ConcurrentRepackTest.testObjectMovedWithinPack(ConcurrentRepackTest.java:129)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at junit.framework.TestCase.runTest(TestCase.java:164)
	at junit.framework.TestCase.runBare(TestCase.java:130)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:120)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
After pruning the other changes, it still crashes , even with mvn clean test

HashCode /home/me/SW/EGIT.contrib/org.spearce.jgit.test/trash/trash1240354367548.0/.git/objects/pack/pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.pack = 327983069 HashCode /home/me/SW/EGIT.contrib/org.spearce.jgit.test/trash/trash1240354367548.0/.git/objects/pack/pack-df2982f284bbabb6bdb59ee3fcc6eb0983e20371.pack = 458811222 HashCode /home/me/SW/EGIT.contrib/org.spearce.jgit.test/trash/trash1240354367548.0/.git/objects/pack/pack-9fb5b411fe6dfa89cc2e6b89d2bd8e5de02b5745.pack = 331392325 HashCode /home/me/SW/EGIT.contrib/org.spearce.jgit.test/trash/trash1240354367548.0/.git/objects/pack/pack-546ff360fe3488adb20860ce3436a2d6373d2796.pack = 547821429 HashCode /home/me/SW/EGIT.contrib/org.spearce.jgit.test/trash/trash1240354367548.0/.git/objects/pack/pack-e6d07037cbcf13376308a0a995d1fa48f8f76aaa.pack = 536578194 HashCode /home/me/SW/EGIT.contrib/org.spearce.jgit.test/trash/trash1240354367548.0/.git/objects/pack/pack-3280af9c07ee18a87705ef50b0cc4cd20266cf12.pack = 885722359 HashCode /home/me/SW/EGIT.contrib/org.spearce.jgit.test/trash/trash1240354367548.0/.git/objects/pack/pack-146aac1f6a11aed8e06af7d9f5cc1b4b8beedb36.pack = 830203467

The hash codes printed are the same everytime it crashes, removing the invalid flags will create these codes and the test succeeds.

HashCode /home/me/SW/EGIT.contrib/org.spearce.jgit.test/trash/trash1240354568171.0/.git/objects/pack/pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.pack = 327983069 HashCode /home/me/SW/EGIT.contrib/org.spearce.jgit.test/trash/trash1240354568171.0/.git/objects/pack/pack-df2982f284bbabb6bdb59ee3fcc6eb0983e20371.pack = 458811222 HashCode /home/me/SW/EGIT.contrib/org.spearce.jgit.test/trash/trash1240354568171.0/.git/objects/pack/pack-9fb5b411fe6dfa89cc2e6b89d2bd8e5de02b5745.pack = 331392325 HashCode /home/me/SW/EGIT.contrib/org.spearce.jgit.test/trash/trash1240354568171.0/.git/objects/pack/pack-546ff360fe3488adb20860ce3436a2d6373d2796.pack = 547821429 HashCode /home/me/SW/EGIT.contrib/org.spearce.jgit.test/trash/trash1240354568171.0/.git/objects/pack/pack-e6d07037cbcf13376308a0a995d1fa48f8f76aaa.pack = 536578194 HashCode /home/me/SW/EGIT.contrib/org.spearce.jgit.test/trash/trash1240354568171.0/.git/objects/pack/pack-3280af9c07ee18a87705ef50b0cc4cd20266cf12.pack = 885722359 HashCode /home/me/SW/EGIT.contrib/org.spearce.jgit.test/trash/trash1240354568171.0/.git/objects/pack/pack-146aac1f6a11aed8e06af7d9f5cc1b4b8beedb36.pack = 830203467

One cannot obviously assume they are the same, but the numbers might be a lead to why it crashes here. Looks like as hash collision and a failure of the "equals" part to distinguish different WindowedFile's.

-- robin
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/WindowedFile.java b/org.spearce.jgit/src/org/spearce/jgit/lib/WindowedFile.java
index 9293eb9..f9e1991 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/WindowedFile.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/WindowedFile.java
@@ -80,6 +80,8 @@
 	/** Total number of windows actively in the associated cache. */
 	int openCount;
 
+	boolean invalid;
+
 	/**
 	 * Open a file for reading through window caching.
 	 * 
@@ -93,6 +95,10 @@ public WindowedFile(final File file) {
 		// value in WindowCache.hash(), without doing the multiply there.
 		//
 		hash = System.identityHashCode(this) * 31;
+		System.out.print("HashCode ");
+		System.out.print(file.getPath());
+		System.out.print(" = ");
+		System.out.println(hash);
 		length = Long.MAX_VALUE;
 	}
 
Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 12 of 17 in “Object access improvements”
  1. 00/10 Object access improvementsShawn O. Pearce, Apr 21, 2009
  2. 01/10 Safely handle closing an already closed WindowedFileShawn O. Pearce, Apr 21, 2009
  3. 02/10 Change empty tree test case to use a temporary repositoryShawn O. Pearce, Apr 21, 2009
  4. 03/10 Replace hand-coded read fully loop with NB.readFullyShawn O. Pearce, Apr 21, 2009
  5. 04/10 Clear the reverse index when closing a PackFileShawn O. Pearce, Apr 21, 2009
  6. 05/10 Introduce a new exception type for an in-place pack modificationShawn O. Pearce, Apr 21, 2009
  7. 06/10 Refactor object database access with new abstractionShawn O. Pearce, Apr 21, 2009
  8. 07/10 Rescan packs if a pack is modified in-place (part 1)Shawn O. Pearce, Apr 21, 2009
  9. 08/10 Scan for new packs if GIT_DIR/objects/pack has been modifiedShawn O. Pearce, Apr 21, 2009
  10. 09/10 Add test cases for loading new (or replaced) pack filesShawn O. Pearce, Apr 21, 2009
  11. 10/10 BROKEN TEST: ObjectLoader stays valid across repacksShawn O. Pearce, Apr 21, 2009
  12. Robin RosenbergApr 21, 2009
  13. Shawn O. PearceApr 22, 2009
  14. Shawn O. PearceApr 22, 2009
  15. 09/10 Add test cases for loading new (or replaced) pack filesShawn O. Pearce, Apr 21, 2009
  16. Shawn O. PearceApr 21, 2009
  17. 08/10 Scan for new packs if GIT_DIR/objects/pack has been modifiedShawn O. Pearce, Apr 21, 2009

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.