https://bz.apache.org/bugzilla/show_bug.cgi?id=57959

            Bug ID: 57959
           Summary: Deadlock in FileHandler.java when log is rotated
           Product: Tomcat 7
           Version: 7.0.62
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: acha...@hotmail.com

Tomcat 7 will deadlock when a log file is rotated.  This issue has been fixed
in latest tomcat 6 and tomcat 8 but not in tomcat 7.

The issue is in following code
(apache-tomcat-7.0.62-src/java/org/apache/juli/FileHandler.java:188)


                } finally {
                    writerLock.writeLock().unlock();
                    // Down grade to read-lock. This ensures the writer remains
valid
                    // until the log message is written
                    writerLock.readLock().lock();
                }
            }


Despite the comment the order is wrong, you have to acquire a read lock then
release write lock to make sure the race condition does not occur.

The correct way to do it is:

                } finally {
                    writerLock.readLock().lock();
                    writerLock.writeLock().unlock();
                }
            }

In tomcat 6
(apache-tomcat-6.0.44-src/java/org/apache/juli/FileHandler.java:187) and tomcat
8 (apache-tomcat-8.0.22-src/java/org/apache/juli/FileHandler.java:186) the
order is correct.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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

Reply via email to