DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40167>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40167

           Summary: Race condition in SoftReferenceCache.java wedges updater
                    thread
           Product: Batik
           Version: 1.6
          Platform: All
        OS/Version: Linux
            Status: NEW
          Severity: critical
          Priority: P2
         Component: Utilities
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]


There is race condition bug in SoftReferenceCache.java that has the net effect
of wrongly putting an entry in the cache with null value. This causes all
subsequent requests for that value to hang forever in Object.wait() (inside
requestImpl()).

The bug stems from the code's failure to discern between the two meanings of
HashMap.get(key) returning null, i.e., (a) the key does not exist in the map, or
(b) the key exists but has a null value.

Sequence of events that trigger this bug:

   1. putImpl(key, ref): key -> ref added to map (ref is a SoftRefKey)
   2. soft reference to value 'ref' is cleared by JVM
   3. clearImpl(key): key is cleared from the map
   4. JVM reference queue thread invokes ref.cleared()
   5. ref.cleared() does cache.map.remove(key), which returns null
   6. null != this, so cleared() then does cache.map.put(key, null)
   7. victim thread invokes requestImpl(key), sees that the map
      contains the key but with null value, and so waits forever

Patch to fix this bug:

--- sources/org/apache/batik/util/SoftReferenceCache.java.orig  2006-08-01
20:35:11.000000000 -0500
+++ sources/org/apache/batik/util/SoftReferenceCache.java       2006-08-02
08:57:12.301341434 -0500
@@ -173,6 +173,8 @@
             SoftReferenceCache cache = SoftReferenceCache.this;
             if (cache == null) return; // Can't really happen.
             synchronized (cache) {
+                if (!cache.map.containsKey(key))
+                    return;
                 Object o = cache.map.remove(key);
                 if (this == o) {
                     // Notify other threads that they may have

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to