https://issues.apache.org/bugzilla/show_bug.cgi?id=46878
Summary: Deadlock in 1.2.15 caused by AsyncAppender and
ThrowableInformation classes
Product: Log4j
Version: 1.2
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: critical
Priority: P2
Component: Appender
AssignedTo: [email protected]
ReportedBy: [email protected]
This is about version 1.2.15. For business reason we have to use two
AsyncAppenders to log the same event to two destinations. In the process we ran
into two issues that together cause deadlock under burst of logging
Problem 1 is when an exception object is part of the logging, a
NullPointerException may be thrown. The bug is in the ThrowableInformation
class' getThrowableStrRep() method, in which the access to the 'rep' field is
not synchronized. As a result, one thread may retrieve an array of null values
instead of the stack trace strings. (Basically rep != null but hasn't been
filled up) When this happens, a null is written to the QuietWriter and the
exception will be thrown. We had to use a work around by creating the
LoggingEvent, call getThrowableStrRep() on the event, and use
Category.callAllAppenders().
Problem 2 is there is a race condition in the AsyncAppender.append() method.
The liveness of the dispatcher thread is checked only once. This is not enough
on systems with intensive logging, since the buffer object may fill up and the
logging thread may be blocked there. If the dispatcher thread dies after the
logging thread started waiting, deadlock will ensue. The death of dispatcher
could be caused by problem 1. The dispatcher thread should at the minimum catch
logging errors and call buffer.notifyAll() in the catch block. And the logging
thread should check for the thread liveness in the while loop. It'd be better
if dispatcher can recover itself.
Lastly, dispatcher liveness should be maintained by a shared variable that is
properly synchronized. Thread.isAlive() is not enough, since a live thread may
be on its way to death (e.g., climbing up the stacks) when this method is
called.
--
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: [email protected]
For additional commands, e-mail: [email protected]