[JGIT PATCH 08/13] Work around Sun JVM bug "Cleared SoftReference not added to queue"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> http://bugs.sun.com/view_bug.do?bug_id=4485942
>
> Normally all soft references cleared by the garbage collector are
> added to the reference queue the reference was created with (if any).
> But if a program happens to call SoftReference.get() after the reference
> has been cleared, but before it has been added to the reference queue it
> will never be added to the reference queue.
...
> This bug can be worked around by keeping track of calls to
> SoftReference.get() that returns null. The only problem is that the
> code must also allow for the behavior to change when/if the bug is
> fixed.

The bug was opened against JDK 1.3.1, reported to still exist in 1.4,
and isn't marked fixed yet despite 1.6 having shipped.

We already have a work around for this in our code.  We mark a reference
as cleared using our own boolean, as we need to work around another bug
in the ReferenceQueue implementation anyway.  So, we try to enqueue the
dead reference when we find it.  If its already enqueued, no harm.  If
we hit the enqueue bug and enqueue it twice, no harm, our cleared flag
will skip the second removal from the queue.  If the bug described in
4485942 exists, we'll enqueue the reference for the GC.

Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx>
---
 .../src/org/spearce/jgit/lib/OffsetCache.java      |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java b/org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java
index 12912d9..e3ed37d 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java
@@ -232,7 +232,7 @@ private V scan(Entry<V> n, final PackFile pack, final long position) {
 					hit(r);
 					return v;
 				}
-				n.dead = true;
+				n.kill();
 				break;
 			}
 		}
-- 
1.6.3.rc1.205.g37f8

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]