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 2015/05/27 21:21:22 UTC

[Bug 57959] New: Deadlock in FileHandler.java when log is rotated

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: achacha@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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 57959] Deadlock in FileHandler.java when log is rotated

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

Violeta Georgieva <vi...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #1 from Violeta Georgieva <vi...@apache.org> ---
Thanks for the report.
The fix is provided for Tomcat 7 trunk and will be available with 7.0.63
onwards.

Regards,
Violeta

-- 
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