Bug 52354

Summary: Protect concurrent accesses to field "org.apache.catalina.tribes.transport.bio.util.FastQueue.inRemove"
Product: Tomcat 7 Reporter: Mohsen Vakilian <reprogrammer>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal CC: reprogrammer
Priority: P2    
Version: trunk   
Target Milestone: ---   
Hardware: PC   
OS: Linux   

Description Mohsen Vakilian 2011-12-18 23:04:53 UTC
Field "org.apache.catalina.tribes.transport.bio.util.FastQueue.inRemove" may be read and written in parallel. Thus, accesses to it should be synchronized. The following is a sequence of method calls from the "run" method of a class that implements "Runnable" to a method that accesses "FastQueue.inRemove" without proper synchronization.

1. org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor.run()
2. org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor.removeFromQueue()
3. org.apache.catalina.tribes.transport.bio.util.FastQueue.remove()

Field "FastQueue.inRemove" is declared at <http://svn.apache.org/repos/asf/!svn/bc/1220560/tomcat/trunk/java/org/apache/catalina/tribes/transport/bio/util/FastQueue.java>.
Comment 1 Mark Thomas 2011-12-23 21:06:21 UTC
There is a concurrency issue but not the one described here. Access to that field is protected by an exclusive lock. It does however need to be volatile.
Comment 2 Mark Thomas 2011-12-23 21:17:24 UTC
Fixed in trunk and 7.0.x and will be included in 7.0.24 onwards.
Comment 3 Mohsen Vakilian 2011-12-24 00:10:25 UTC
Thanks for resolving the visibility issue. Keshmesh <http://keshmesh.cs.illinois.edu/> detected this problem when we ran it on Tomcat using method "org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor.run()" as an entry point.

(In reply to comment #2)
> Fixed in trunk and 7.0.x and will be included in 7.0.24 onwards.