We are running tomcat 6.0.18 with a race detector (http://www.alphaworks.ibm.com/tech/msdk), and find one race condition in class org.apache.catalina.session.ManagerBase field maxActive. Data Race 1 : org.apache.catalina.session.ManagerBase : maxActive Thread "http-8080-3" : Tid 34 : WRITE Lock Set : [ ] [org.apache.catalina.session.ManagerBase : add(Lorg/apache/catalina/Session;)V : : 741] [org.apache.catalina.session.StandardSession : setId(Ljava/lang/String;)V : : 368] [org.apache.catalina.session.ManagerBase : createSession(Ljava/lang/String;)Lorg/apache/catalina/Session; : : 827] [org.apache.catalina.session.StandardManager : createSession(Ljava/lang/String;)Lorg/apache/catalina/Session; : : 291] [org.apache.catalina.connector.Request : doGetSession(Z)Lorg/apache/catalina/Session; : : 2324] [org.apache.catalina.connector.Request : getSession(Z)Ljavax/servlet/http/HttpSession; : : 2074] [org.apache.catalina.connector.RequestFacade : getSession(Z)Ljavax/servlet/http/HttpSession; : : 833] [org.apache.catalina.connector.RequestFacade : getSession()Ljavax/servlet/http/HttpSession; : : 844] [com.ecyrd.jspwiki.auth.AuthenticationManager : login(Ljavax/servlet/http/HttpServletRequest;)Z : : 270] ........ Thread "http-8080-1" : Tid 32 : READ Lock Set : [ ] [org.apache.catalina.session.ManagerBase : add(Lorg/apache/catalina/Session;)V : : 740] [org.apache.catalina.session.StandardSession : setId(Ljava/lang/String;)V : : 368] [org.apache.catalina.session.ManagerBase : createSession(Ljava/lang/String;)Lorg/apache/catalina/Session; : : 827] [org.apache.catalina.session.StandardManager : createSession(Ljava/lang/String;)Lorg/apache/catalina/Session; : : 291] ........ Here is the code snip of ManagerBase.java public void add(Session session) { sessions.put(session.getIdInternal(), session); int size = sessions.size(); 1-> if( size > maxActive ) { 2-> maxActive = size; } } Statement 1 and statement 2 should executed in an atomic manner. One fix to this problem is to move statement 1 and statement 2 into a synchronized block.
Fixed in trunk and proposed for 6.0.x. I came very close to marking this as WONTFIX because I don't think the thread safety issues are going to cause any harm.
(In reply to comment #1) > Fixed in trunk and proposed for 6.0.x. > I'll go to trunk and have a look. > I came very close to marking this as WONTFIX because I don't think the thread > safety issues are going to cause any harm. Right, the boundary of harmful race and benign race is not very clear.
This has been fixed in 6.0.x and will be included in 6.0.27 onwards.