Mantis - Resin
Viewing Issue Advanced Details
2248 minor N/A 12-12-07 15:18 12-17-07 14:51
aozarov  
ferg  
normal  
closed 2.1.x  
fixed  
none    
none 3.0.25  
0002248: access to SessionManager#timeout is not synchronized
Both Crod and Alarm threads can call this method simultaneously.
The call to sessionList.clear() is outside of the synchronized block which can cause one thread to clear the list while the other one is processing it. I didn't check all the side-effects of this problem but can imagine that some sessions will not be cleaned/removed appropriately which may lead to some memory leaks.
Also, I am not sure if that can leave the ArrayList itself in an inconsistent state.
thread dump extract:

"resin-alarm" daemon prio=10 tid=0x00002aab502d2c00 nid=0x5180 waiting for monitor entry [0x000000004123a000..0x000000004123aba0]
   java.lang.Thread.State: BLOCKED (on object monitor)
    at com.caucho.http.session.SessionManager.timeout(SessionManager.java:1009)
    - waiting to lock <0x00002aaab683fbd0> (a com.caucho.util.LruCache)
    at com.caucho.server.http.Application.timeout(Application.java:3667)
    at com.caucho.server.http.VirtualHost.timeout(VirtualHost.java:1323)
    at com.caucho.server.http.ServletServer.timeout(ServletServer.java:1808)
    at com.caucho.server.http.ServletServer.handleAlarm(ServletServer.java:1758)
    at com.caucho.util.Alarm$AlarmThread.evaluateAlarm(Alarm.java:319)
    at com.caucho.util.Alarm$AlarmThread.run(Alarm.java:279)

"resin-cron" daemon prio=10 tid=0x00002aab4ec00000 nid=0x517f runnable [0x0000000041139000..0x0000000041139c20]
   java.lang.Thread.State: RUNNABLE
    at com.caucho.http.session.SessionManager.timeout(SessionManager.java:1017)
    - locked <0x00002aaab683fbd0> (a com.caucho.util.LruCache)
    at com.caucho.http.session.SessionManager.cron(SessionManager.java:1040)
    at com.caucho.server.http.Application.cron(Application.java:3701)
    at com.caucho.server.http.VirtualHost.cron(VirtualHost.java:1370)
    at com.caucho.server.http.ServletServer.cron(ServletServer.java:1950)
    at com.caucho.server.http.ServletServer.handleCron(ServletServer.java:1780)
    at com.caucho.util.Cron$CronThread.evaluateCron(Cron.java:199)
    at com.caucho.util.Cron$CronThread.run(Cron.java:163)


Notes
(0002584)
ferg   
12-17-07 14:51   
2.1.x is frozen and this issue does not apply to 3.0, since it uses a single alarm thread, i.e. that list is only single-threaded.