You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2010/02/22 04:41:23 UTC

DO NOT REPLY [Bug 48790] New: Race condition in org.apache.catalina.session.ManagerBase:maxActive

https://issues.apache.org/bugzilla/show_bug.cgi?id=48790

           Summary: Race condition in
                    org.apache.catalina.session.ManagerBase:maxActive
           Product: Tomcat 6
           Version: 6.0.18
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: Catalina
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: qiyaoltc@gmail.com


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.

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 48790] Race condition in org.apache.catalina.session.ManagerBase:maxActive

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48790

Yao Qi <qi...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |qiyaoltc@gmail.com

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 48790] Race condition in org.apache.catalina.session.ManagerBase:maxActive

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48790

--- Comment #2 from Yao Qi <qi...@gmail.com> 2010-03-10 01:22:50 UTC ---
(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.

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 48790] Race condition in org.apache.catalina.session.ManagerBase:maxActive

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48790

--- Comment #1 from Mark Thomas <ma...@apache.org> 2010-03-09 22:23:07 UTC ---
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.

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org